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) ?

5 visualizzazioni (ultimi 30 giorni)
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.

Risposte (2)

Sanchali Purandare
Sanchali Purandare il 16 Gen 2011
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 il 26 Gen 2011
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

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by