Effacer les filtres
Effacer les filtres

Repeat in counter

1 vue (au cours des 30 derniers jours)
Michael
Michael le 11 Juil 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!

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by