Filter löschen
Filter löschen

Repeat in counter

1 Ansicht (letzte 30 Tage)
Michael
Michael am 11 Jul. 2011
I used a counter and an xlswrite function in a loop. For each iteration of the loop, a new value is calculated. I used the following counter so that for each round of the loop, the value would be pasted in the next consecutive cell below the previous:
blah = {'1';'2'};
count = 1;
for y = 1:length(blah)
fileid = [blah{y},'.csv]
data = xlsread(fileid);
***(((my calculations that produces X)))***
xlswrite('Data.xls', X, sprintf('A%i:A%i',count, count+1))
count = count+1;
end
The problem is that when it writes the value into the excel document for each loop it writes the same value in two consecutive cells each time. Any ideas on what I need to do to fix this?
Thanks!

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 11 Jul. 2011
Well, you specified to write to A1:A2 for example, which is two cells. Try sprintf('A%i:A%i',count,count)

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by