XLSwrite to write in a different column in each iteration

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.

2 件のコメント

Andrei Bobrov
Andrei Bobrov 2012 年 4 月 4 日
What is it 'rr2'? Array 2D or 1D?
ARS
ARS 2012 年 4 月 4 日
Hi Andrei,
RR2 is a Dataset Array of dimension 6x41 .
I need the first column of RR2 (a list of names) to be sorted by col 1 to 40.....and the sorted named list be exported to excel in a different column in each iteration.
or Any procedure which makes this desired matrix in matlab and the whole sheet be written to MATLAB...
Thanks.

サインインしてコメントする。

 採用された回答

ARS
ARS 2012 年 4 月 5 日

1 投票

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.

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2012 年 4 月 5 日

0 投票

EDITED on Ahmad comment
[~,isrd] = sort(double(rr2(:,2:end)));
N = cellstr(rr2(:,1));
xlswrite('rr2.xlsx',N(isrd));

1 件のコメント

ARS
ARS 2012 年 4 月 5 日
Thanks Andrei...This produces the following errors:
??? Undefined function or method 'sort' for input arguments of type 'dataset'.
?? Undefined variable rr.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

製品

タグ

質問済み:

ARS
2012 年 4 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by