MATLAB Answers

How to write data array as excel file (keeping column orientation)

2 ビュー (過去 30 日間)
wd8555
wd8555 2020 年 9 月 17 日
コメント済み: wd8555 2020 年 10 月 1 日
I have 2 variables each contain numerica data (501X1double). I want to combine each column and extract as excel file keeping the column orientation, how to do this best?
First: I create Table: T=array2table({A,B},'VariableNames',{'A','B'})
Then: I write Table: writetable(T,'exceloutput.xlsx')
Problem: data is row oriented, i.e. all data is in first first row of excel sheet.
How to keep the column orientation?

  0 件のコメント

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

採用された回答

Mrunmayee Gaikwad
Mrunmayee Gaikwad 2020 年 9 月 21 日
In the line:
T=array2table({A,B},'VariableNames',{'A','B'})
the use of curly braces in combining two arrays {A,B}, would return a 1x2 cell array and not a numeric matrix. This caused the table to contain all the data in a single row.
To get a numeric matrix from combining the arrays use square braces instead of curly braces like:
T=array2table([A,B],'VariableNames',{'A','B'})
For more information on combining matrices see the following link:

  1 件のコメント

wd8555
wd8555 2020 年 10 月 1 日
Thank you!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by