using textscan to load numbers from txt file

조회 수: 4 (최근 30일)
DoVile Last Name:
DoVile Last Name: 2013년 1월 1일
I am using textscan
tmp = textscan(fid,'%4f %q %f %f %f %f %f %f %f %f','treatAsEmpty', 'n/a');
to load data which looks like (skipping few columns)
1950 "Afghanistan" 8150.368
I get the year and the country without problems, but the third number is instead loaded as 0.8150...
I tried using something like %6.3f for the format input, but that just returns some dimension mismatch.
What am i doing wrong ?
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2013년 1월 1일
can you post a sample of your data (3 lines)
DoVile Last Name:
DoVile Last Name: 2013년 1월 1일
Sure
1950 "Afghanistan" 8150.368 n/a n/a n/a n/a n/a n/a n/a
1951 "Afghanistan" 8284.473 n/a n/a n/a n/a n/a n/a n/a
1952 "Afghanistan" 8425.333 n/a n/a n/a n/a n/a n/a n/a
Alot of n/a values for the early years :)

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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 1월 1일
Your answer is correct. Maybe its displaying something like
ans =
1.0e+03 *
8.1504
8.2845
8.4253
Check this
a=tmp{3};
a(1)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cardiology에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by