a problem with "for loop" that contains "if staetement"
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
Dear all,
I have the following code
list= {'jj.xlsx' ...
'rt.xlsx' ...
'gt.xlsx' }
for i=1:length(list)
data = [];
[N6,T6,R6] = xlsread(filename,i+2); %
[N5,T5,R5] = xlsread(filename,i+1);
if all(isnan( R6{2,4} ))
N6(1,:) = [];
end
if all(isnan( R5{2,4} ))
N5(1,:)=[];
end
fdata = [data R6(1:size(T6,1),1:size(T6,2)) raw5(1:size(T5,1),3:size(T5,2)) ];
xlswrite(list{i} , fdata);
the only problem that I have is that I do not know how to handle the part
data = [];
fdata = [data R6(1:size(T6,1),1:size(T6,2)) raw5(1:size(T5,1),3:size(T5,2)) ];
xlswrite(list{ii} , fdata);
inside the “for loop” for each i.
What I am seeking for is something like
data(i) = [];
fdata(i) = [data R6(1:size(T6,1),1:size(T6,2)) raw5(1:size(T5,1),3:size(T5,2)) ];
xlswrite(list{i} , fdata(i));
could you help me fix the above code?
Thanks
4 Kommentare
Ryan
am 6 Jul. 2012
I am trying to understand your problem and believe you're having an issue with this:
xlswrite(list{ii},fdata);
This should save the fdata under the appropriate name from your list variable (although your for loop uses 'i' as the counter, not 'ii') - is that not what you are trying to do? Since fdata is redefined in the loop every iteration, you shouldn't need to specify any additional things for fdata. Something such as fdata(i) will save the ith value of fdata.
antonet
am 6 Jul. 2012
Bearbeitet: Walter Roberson
am 6 Jul. 2012
Jan
am 7 Jul. 2012
@antonet: You cannot format the code? Start the code with an empty line, then indent all lines using two spaces, add an empty line at the end. I cannot imagine a terminal, which does not allow this.
Antworten (0)
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!