How can I read data file with maximum float point available line by line?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello, I have two routines reading different data files (txt). First data file is like that:
2.281000003 2.593500003 2.749750003 3.062250003...
Routine is:
fid = fopen('v2-eq3.txt','r');
atensao=fscanf(fid,'%f');
fclose(fid);
Result:
2.2810
2.5935
2.7498
3.0623...
Why I can't read the original file correctly?
The second data file (txt) is like that:
0.0141451080390089-0.00224036502008852i
0.0163497695135516-0.00258954909383903i
0.0141451080390089-0.00224036502008852i...
Routine is:
fid = fopen ('i2-eq3.txt','r');
ii = 1;
while ~feof(fid)
acorrente(ii, :) = str2num(fgets(fid));
ii = ii + 1;
end
fclose(fid);
Result:
0.01415-0.0022i
0.0163-0.0026i
0.0141-0.0022i...
So, what's wrong? Why I can't read the original files correctly? Could someone teach me? Thanks a lot.
댓글 수: 0
채택된 답변
Walter Roberson
2014년 2월 13일
At the MATLAB command line, give the command
format long g
then display Result again.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 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!