Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

XLS and for loops

조회 수: 1 (최근 30일)
Alessandro Innocenti
Alessandro Innocenti 2013년 2월 8일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi! I have some folders, and in these folders I have xls files. I would like create a program for reading these files, copying a single line and re-writing the lines in a new xls files.
So the first step is allowing the program to know which xls files read:
List=dir(['C:\Documents and Settings\folder1\' filesep '*.xls']);
n1= length(List)
for i=1:1:n1
x=List(i,:).name
end
...and I have a problem! My idea was to create a X matrix where there are file names. Then I'll create a second part (in the for loop) with xlsread program and the X matrix ( may be: A=xlsread(X)), and then a third part for copying the single line and rewriting. So far, my problems are: - how can I avoid to overwrite the data in the matrix X? - What should I write for reading the xls file?
I hope i was clear. Thank you and sorry for my bad english... Ale

답변 (2개)

Walter Roberson
Walter Roberson 2013년 2월 8일
x{i} = List(i,:).name;
and when you want to get back an individual name, x{i} again for appropriate "i"

Jan
Jan 2013년 2월 8일
편집: Jan 2013년 2월 8일
Data = cell(1, nFiles);
for k = 1:nFiles
file = List(i,:).name;
Data{k} = xlsread(file);
end
Less cryptic names of variables allow to keep the overview in grater programs.

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by