Error using eval when load many files in recursive
23 views (last 30 days)
Show older comments
I want to load many files, i.e.
load('SST_mw_region6.mat','sst','time','lon','lat');
where "6" can be vary from 1 to 20
I did try using :
for k=1:20
eval(['load SST_mw_region' num2str(k) '.mat','sst','time','lon','lat';'])
end
I am not sure where I have to put ' ' and how many of them
Thanks
Dwi
0 Comments
Answers (1)
Walter Roberson
on 20 Sep 2019
Don't use eval(). Construct your filenames using sprintf() and use the function form of load instead of the command form.
Note that when you do not assign the output of load() to a variable, that each iteration each of the variables you just loaded will be overwritten completely with the variables you just loaded.
See Also
Categories
Find more on Calendar in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!