So I basically have a small script in MatLab which I'm using in a much larger program. This script essentially keeps writing data to an Excel file.
The script writes data horizontally across cells and is as follows:
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
The script works perfectly when writing data between columns A-Z. However it crashes once it reaches column Z. How can I modify the script so that it can keep writing beyond column Z to AA, AB, etc (it needs to go right the way down to CR).
Thanks.
char(64+k). Once you reach the ASCII code forZ(90) you will get the ASCII code of[(91). You need to handle this case adding a second char on the left and reset the first one to 64 (ASCII for 'A'). This way you will get without problems up to ZZ.