Str2num error
2 次查看(过去 30 天)
显示 更早的评论
I am getting the following error:
Error using str2num
Too many input arguments.
Error in b (line 8)
daystr = str2num(i,'%o');
Here is the portion of the code:
numFiles = 31;
startRow = 1;
endRow = inf;
myData = cell(1,numFiles);
for i = 0:numFiles
if i<10
daystr = ['0', str2num (i)];
else
daystr = str2num(i);
end
filename = ['TS2004.07.',daystr,'.00','.txt'];
mtx(i) = load(filename);
end
I want to load all text files, 'TS2004.07.0000.txt' to 'TS2004.07.3100.txt'.
0 个评论
回答(2 个)
the cyclist
2016-9-10
编辑:the cyclist
2016-9-10
Don't leave a space between the function name and the parentheses. Also, I think you meant to use num2str here, not str2num. Try
num2str(i)
0 个评论
Naoki Ishibashi
2016-9-10
2 个评论
Walter Roberson
2016-9-10
You cannot index a structure at index 0. You will need to add 1, so
mtx(i+1) = load(filename);
See also
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!