Why I have problem in my program.
Show older comments
I am getting the following error
Attempt to execute SCRIPT load as a function:
/Users/naoki/Documents/MATLAB/Add-Ons/TS2004.07/load.m
Error in load (line 17)
mydata{i,k} = load(filename);
And this is my programming:
numFiles = 31;
mydata = cell(31, 7);
for i = 1:numFiles
if i<10
daystr_j = ['0', num2str(i)];
else
daystr_j = num2str(i);
end
for k = 0:7
j = 3*k;
if j<10
daystr_j = ['0', num2str(j)];
else
daystr_j = num2str(j);
end
filename = ['TS2004.07.',daystr_i,'.',daystr_j,'00.txt'];
mydata{i,k} = load(filename);
end
end
I want to load all text datas, TS2004.07.01.0000.txt to TS2004.07.31.2100.txt.
Please give me any advice.
1 Comment
Walter Roberson
on 10 Sep 2016
By the way:
daystr_i = sprintf('%02d', i);
saves you from having to test the value or add the leading '0' or do the num2str()
Accepted Answer
More Answers (1)
James Ryan
on 10 Sep 2016
0 votes
It could be a simple bug. You use daystr_i and daystr_j in the filename, but you never set daystr_i. It looks like you set daystr_j twice by accident. Actually it might be a good idea to use variable names which don't look so much alike.
Try that and respond if there's still a problem.
1 Comment
Naoki Ishibashi
on 11 Sep 2016
Categories
Find more on Call Java from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!