How can I convert a table into separate columns?
35 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/323320/image.jpeg)
I tried to use table2array to turn the table with separate columns. However, matlab did not allow me to do so. I need to turn them into columns as I want to use the retime function to do daily average calculation afterwards. But before using retime function, I will need to be able to produce a timetable with the variables in each column in it. Any suggestions?
0 Commenti
Risposte (2)
Gaurav Aggarwal
il 28 Giu 2020
Hi Oi,
table2array tries to create a homogeneous array from the table i.e. the table should have same data type throughout. However, as I see it, your table consists of multiple data type and thus the error. Read more here:https://www.mathworks.com/help/matlab/ref/table2array.html
You can try creating a cell array and then extract the columns
cell_name = table2cell(table_name); %% converts table structure to cell structure
ithcol = cell_name(:,i); %% extracts ith column
var = cell2mat(ithcol); %% converts cell array to matrix (assumes same data type throughout column)
Hope this helps. Thanks.
0 Commenti
Steven Lord
il 28 Giu 2020
If you want to turn this into a timetable use table2timetable instead of table2array and array2timetable like I think you are trying to do.
0 Commenti
Vedere anche
Categorie
Scopri di più su Data Type Conversion 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!