MATLAB: Repeat in counter

countfor loopxlswrite

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!

Best Answer

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