How to load files on a loop

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?

回答(1 个)

f=20:1020;
for k=1:length(f)
fileName=sprintf('x.%04d.FIT',f(k));
a{k}=fitsread(fileName);
end

类别

在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by