I would like to store files in an array of type A(10,1:853,1:853) using csvread and a for loop. How can I do this?

1 view (last 30 days)
My csv files are spectra data of the type A1a(1:853,1:853). Column 1 contains wavelength information, Column 2 contains intensity information. I have multiple csv files in a folder, A1a, A1b, A1c.....A1k.csv I would like to store these files in an array of type A(10,1:853,1:853) using csvread and a for loop. How can I do this? Thank You!

Accepted Answer

Guillaume
Guillaume on 7 Oct 2015
Assuming all your csv files have exactly the same number of elements:
finalletters = 'a':'k';
A = zeros(numel(finalletters), 853, 853);
for letteridx = 1:numel(finalletters)
A(letteridx, :, :) = csvread(sprintf('A1%c.csv', finalletters(letteridx)));
end

More Answers (0)

Categories

Find more on Characters and Strings 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!