copy data from array to table

15 Ansichten (letzte 30 Tage)
Marc Elmeua
Marc Elmeua am 9 Feb. 2020
Kommentiert: Marc Elmeua am 9 Feb. 2020
Dear all,
I have an array with n number of columns and 100 rows. I would like to copy them into a table with the same dimension that has the names of the variables already written.
any ideas?
Thanks in advance!

Akzeptierte Antwort

BN
BN am 9 Feb. 2020
Bearbeitet: BN am 9 Feb. 2020
Hello, If A is your array and you want to have a table based on it, you can simply usearray2table.
Table = array2table(A);
If you want to change the variable names, so you can do this nicely, otherwise variable names stay what they are at the A
Table = array2table(A,'VariableNames',{'firstvariable','secondvariable','etc...'})
Here is an example for you:
A = rand(10,5); % here is random array with 10 rows and 5 columns
Table = array2table(A,'VariableNames',{'varname_1','varname_2','varname_3','varname_4','varname_5'}); %convert it to table and change the variable names
Best Regards
  5 Kommentare
Marc Elmeua
Marc Elmeua am 9 Feb. 2020
Thanks Behzad, that's exactly what I needed.
I do have an array and a table, but once I transform the array to table I have two tables. So that's perfect! thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by