MATLAB: I have problem in the program.

for looptest load

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.

Best Answer

You have written a script called load.m:
/Users/naoki/Documents/MATLAB/Add-Ons/TS2004.07/load.m
That is preventing you from using the MATLAB core load function. This is called ‘overshadowing’, and is to be absolutely avoided.
The solution is to name your function something else, like ‘my_load.m’ or something even more descriptive of its function.
Related Question