Convert string containing number to number only

조회 수: 4 (최근 30일)
lafnath p
lafnath p 2016년 10월 26일
댓글: Walter Roberson 2016년 10월 26일
i have 2 strings in a file in line 12 and 13.
line 12:'index_n=12'
line 13:'index_m=17'
i want to read file from start and get values as X=12 and Y=17
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 10월 26일
Please do not ask the same question multiple times! If you do not understand an answer or it does not work for you, reply there instead of starting a new Question on the same topic!

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

답변 (1개)

KSSV
KSSV 2016년 10월 26일
fid = fopen('textfile','rt') ;
S = textscan(fid,'%s','delimiter','\n') ;
fclose(fid) ;
S = S{1} ;
S has all the information of your text file. You can access your line 12 and 13 using S{12}, S{13}. And proceed according to your yesterdays question.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by