MATLAB: Saving multiple imported files

importmultiple files

Hi
I am trying to import multiple (305) files into Matlab. They are in ascii format with a filetype named .spt. The files are not rectangular, however from row[12],column[0] [12,0] the file becomes rectangular and hence it is this part I wish to import.
I have used the code shown below but I cannot make it save every separate file, it only saves the last file which is not what I require.
files = dir('*.spt');
for i=1:length(files)
Spt(i)=[eval(['csvread(''' files(i).name ''',12,0)' ])];
end
Please can someone explain how to save the files individually withouth having to go through each file separately.
Thanks in advance

Best Answer

  • Does this solve:
    Spt = cell(length(files),1)
    for i=1:length(files)
    Spt(i)= {csvread(files(i).name,12,0)};
    end
    Oleg