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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by