Saving multiple imported files

조회 수: 1 (최근 30일)
Jennifer
Jennifer 2011년 2월 17일
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

채택된 답변

Oleg Komarov
Oleg Komarov 2011년 2월 17일
Does this solve:
Spt = cell(length(files),1)
for i=1:length(files)
Spt(i)= {csvread(files(i).name,12,0)};
end
Oleg
  댓글 수: 2
Jennifer
Jennifer 2011년 2월 17일
Thank you for your reply. I am attempting to generate 305 variables from the imported values.
Unfortunately when I attempt to run your code I get the following error.
??? Conversion to cell from double is not possible.
Any help appriciated :)
Jennifer
Oleg Komarov
Oleg Komarov 2011년 2월 17일
My mistake, forgot {}. Also repreallocated Spt as column cell array.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by