Index exceeds matrix dimensions.
2 次查看(过去 30 天)
显示 更早的评论
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
1 个评论
Image Analyst
2016-2-18
I'll fix your formatting but for next time, read this: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
采纳的回答
Image Analyst
2016-2-18
Call fgetl() 4 times before the loop to read and throw away the first 4 header lines.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!