How to read data from text file upto some point defined by "1"?
古いコメントを表示
I'm trying to read data from a number of text files (using a loop) using fscanf upto some point in the file where "1" occurs. I cannot set the "size" in fscanf(fid,'%f',size) because the "1" doesn't occur at the same place in each file. Is there a way to tell Matlab to scan only upto the "1" by something like this (it helps because no data point is equal to "1"):
while fscanf(fid,'%f',1)~=1
scan=fscanf(fid,'%f')
end
3 件のコメント
Star Strider
2014 年 11 月 30 日
I don’t have any recent experience with fgetl but it might be what you want. Otherwise, you may have to read in the entire file and then test it.
Rinu
2014 年 11 月 30 日
dpb
2014 年 11 月 30 日
What's the form of the text? Is the objective the first character '1' and is it important to be that precise character or the line containing the character or what? What's the desired result?
So many questions, so few answers/details... :)
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Import and Export についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!