How to combine multi column cell in table with commas for excel?

5 ビュー (過去 30 日間)
Eva Herbst
Eva Herbst 2020 年 2 月 18 日
回答済み: Navya Seelam 2020 年 2 月 21 日
Hi, I have made a table in Matlab with various columns. Some cells of the table (for example for columns A and B) have multiple columns.
When I export this to excel it divides these up and gives me a format of columns with A_1,A_2,A_3 etc.
The data is actually a triplet of datapoints, so I want to combine the data for A into one column by using commas as a deliminator.
So for example, get an output with the first row of column A saying 33.08,24.23,5.0506
I assume I somehow need to combine the datapoints with commas before creating the table.
Is there any way to do this?
Thank you very much,
Eva

回答 (1 件)

Navya Seelam
Navya Seelam 2020 年 2 月 21 日
You can try creating table from string array rather than numeric array to combine the data for A into one column as shown below
A=[133.08 24.23 5.0506;114.65 -33.555 12.999];
Astr=num2str(A,'%5f,');
T=table(Astr(:,1:end-1));
writetable(T,'data.xlsx');
Please refer to this link to understand the inputs arguments to num2str.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by