Clear Filters
Clear Filters

Repeat in counter

1 view (last 30 days)
Michael
Michael on 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!

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 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)

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!