How do I generate the range of data to be written to in an excel sheet dynamically when using XLSWRITE in a loop in MATLAB 7.9 (R2009b) ?

8 次查看(过去 30 天)
I would like to write to a new range of data cells in an excel sheet, based on the loop index (with a for loop), dynamically.

回答(2 个)

Sanchali Purandare
Sanchali Purandare 2011-1-16
GENVARNAME can be used to dynamically generate the range of cells to which data is written, in the following manner:
A = [1 2 3; 4 5 6]
for i = 1:2
varname = genvarname(['A' i]);
xlswrite('testing.xls',A(i,:),'Sheet1',varname);
end

Richard de Garis
Richard de Garis 2011-1-26
If it helps, I just published a function on the File Exchange that will enable you to calculate Excel ranges if you know your start cell (or range), the row and column offsets and the row/column size you want. http://www.mathworks.com/matlabcentral/fileexchange/30180-calculate-excel-range

产品

Community Treasure Hunt

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

Start Hunting!

Translated by