MATLAB: XLSwrite to write in a different column in each iteration

MATLABsortxlswrite

Hi all,
I am Sorting the first column of a Dataset Array by using sortrows() and writing the sorted column(values) as it is to excel sheet via XLS write by using the following:
for k=1:40,
sorted=sortrows(rr2,k);
xlswrite('rr2.xls', sorted.Assets , 'XLsheet',['A' num2str(k)]);
end
but the above code changes the row number with counter….I want to write the sorted values to the next excel column in each iteration,,,for example columns from A to AN.
How can I do this?
Regards,
AMD.

Best Answer

Hi,
This solves the purpose...first create a dataset array of sorted names and then export to excel....
for k=1:39,
sorted=sortrows(rr2,k);
sorted1(:,k)=sorted(:,1);
end
export(sorted1,'XLSfile','rr2.xls');
where sorted,rr2 and Sorted1 are dataset arrays of dimension 6x40.
Related Question