How to load files on a loop
Show older comments
I'm trying to load files named as 'x.0020.FIT'....'x.0021.FIT' etc., and there are around 1000 files.
I used
a = fitsread('x.0020.FIT')
which imports one file at a time, each with a different variable. Is it possible to do this on a loop?
Answers (1)
David Hill
on 8 Dec 2020
f=20:1020;
for k=1:length(f)
fileName=sprintf('x.%04d.FIT',f(k));
a{k}=fitsread(fileName);
end
Categories
Find more on Loops and Conditional Statements 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!