How can I select a specific line in a text file base on a specific string in that line?

2 ビュー (過去 30 日間)
I am trying to extract rows from a .txt file that start with a specific string. For example in the attached .txt file, I would like to only extract the values from the lines with 'CR5' into a table. My end goal here is to be able to plot the values.
Thanks.

採用された回答

Rik
Rik 2020 年 7 月 18 日
編集済み: Rik 2020 年 7 月 18 日
Read the entire file and split by newline character (e.g. with my readfile function). Then you can parse line by line in a loop, or use functions like contains.
  4 件のコメント
Jestoni Orcejola
Jestoni Orcejola 2020 年 7 月 19 日
It is a string array and I would like like to convert it to a numeric array. Using str2double results in an error. The goal is to extract the last value in the row for plotting porpuses.
Image Analyst
Image Analyst 2020 年 7 月 19 日
Try sscanf() or textscan().

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by