Convert string containing number to number only
6 次查看(过去 30 天)
显示 更早的评论
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
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
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Data Preparation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!