Matlab Script won't write to Excel past column Z?

Hey guys, so I have a simple script that is part of a much larger program in MatLab. The simple script simply writes certain output to an Excel file:
function writevar(x,k,filename)
col = char(64+k);
N = size(x,1);
Rg = sprintf([col '1:' col '%i' ],N);
xlswrite(filename,x,Rg);
end
I'm writing over 100 individual things however the script gives an error and won't write past column Z. I'm using the script via the following:
writevar({randA{counter}},counter,filename);
If anyone could point out how to modify the script or my use of it to continue writing to Excel past the Z column that would be much appreciated!
Thanks.

Weitere Antworten (1)

Steven Lord
Steven Lord am 4 Jul. 2016

1 Stimme

The column after Z is AA. You need to modify your code that defines col to handle this. Or just omit the range and let xlswrite write starting at the upper-left corner and go as far as it needs to go.

3 Kommentare

I'm not sure how to modify the code to allow column to handle this, would you mind pointing me in the right direction?
Hi,
is anyone find out how the solution is. i have a problem on this too. i'd like to generate data more than 26 column like AA, AB, AC and so on can anyone help?
Regards,
I posted links to two File Exchange contributions that accept a numeric column number and return a lettered column name.

Melden Sie sich an, um zu kommentieren.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by