Index exceeds matrix dimensions.

조회 수: 2 (최근 30일)
Jovos
Jovos 2016년 2월 18일
답변: Image Analyst 2016년 2월 18일
Hi, I'm trying to read the raw data from a txt file. Read the file as an array of strings. Then transfer string to num and get the year data. But it shows that the index exceeds matrix dimensions. Anyone help?
filename = input('Please enter the file name: ');
fid01 = fopen(filename,'r');
for i = 6 : 414
line = fgets(fid01);
z = strread(line,'%s');
year = str2num(z{1});
disp(year)
end

채택된 답변

Image Analyst
Image Analyst 2016년 2월 18일
Call fgetl() 4 times before the loop to read and throw away the first 4 header lines.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by