Fgetl in a while loop.
이전 댓글 표시
In the code in the attached picture, does the first fgetl read the first line (Apple) and str2num(fgetl(file) read the second line (65.1)?
댓글 수: 4
You could very easily try it yourself: create that file, and write out that code. Then you would know what it does, you would gain experience with MATLAB, and you would have some working code. The more you try yourself, the more you read the documentation, the more you will learn.
As an aside: do not use str2num, the function str2double is more robust.
Jan
2017년 4월 3일
fscanf is even smarter than str2double(fgetl).
Lucas Buckels
2017년 4월 4일
Lucas Buckels
2017년 4월 4일
답변 (1개)
Walter Roberson
2017년 4월 4일
0 개 추천
"does the first fgetl read the first line (Apple) and str2num(fgetl(file) read the second line"
Yes.
Question for you: what name is going to be reported if the file is empty?
카테고리
도움말 센터 및 File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!