フィルターのクリア

How to use xlswrite with cell arrays in a loop?

1 回表示 (過去 30 日間)
gsourop
gsourop 2019 年 1 月 17 日
コメント済み: gsourop 2019 年 1 月 17 日
Hi everyone,
Suppose that I have the following cell array:
AA = cell(10,1);
for i = 1 : 10
A = randn(20,1);
AA{i,1} = A;
end
And I want to write in Excel The rows of AA in spreadsheets j. For example,
for i=1
xlswrite('Example.xls', AA{1,1},'Sheet1','a1')
for i=2
xlswrite('Example.xls', AA{2,1},'Sheet1','b1')
and so on
How could I use a loop to avoid re-writing the same command 10 times?

採用された回答

Jan
Jan 2019 年 1 月 17 日
編集済み: Jan 2019 年 1 月 17 日
for k = 1:10
Range = [char('a' + k - 1), '1']
xlswrite('Example.xls', AA{k,1}, 'Sheet1', Range)
end
The conversion to the Excel range fails for more than 27 columns. Prefer a stable function instead, e.g. https://www.mathworks.com/matlabcentral/fileexchange/58917-getexcelrange-rowlimits-columnlimits
  1 件のコメント
gsourop
gsourop 2019 年 1 月 17 日
Thank you for your answer!
However, this command can support only up to 'z', whereas Excel contains columns AA, AB etc.. . So, if AA is a cell(32,1) and i = 1:32, for example, I cannot generalize this command.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by