Azzera filtri
Azzera filtri

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

8 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Navya Seelam
Navya Seelam il 21 Feb 2020
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.

Categorie

Scopri di più su Tables in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by