load ascii data with multiple name
Show older comments
dear all,
I have some data with name ZA000060.TXT, ZA000120.TXT, ZA000180.TXT ..... at the same time I load data with :
for k=60:60:300
aa = sprintf('%d',k);
load (['ZA0000' aa '.TXT'],'AAA')
end
but there is error when load second data because the zero number.
unable to read file "ZA0000120.TXT"
Any help would be great,
Best regard,
5 Comments
@gugum gumbira : Why do you think that " error when load second data because the zero number" ?
You don't give us the complete error message, and there is no reason why a zero digit in a filename would cause any error. Please show us the complete error message.
Also note that it would be much better to load the data into one cell array:
V = 60:60:300;
C = cell(size(V));
for k = 1:numel(V)
filename = sprintf('ZA000%03d.TXT', V(k));
C{k} = load(filename);
end
Do NOT load the variables individually, this will make your code much more complicated.
Edit: simplify example code.
gugum gumbira
on 13 Apr 2016
gugum gumbira
on 15 Apr 2016
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!