How can I convert a string matrix into a table?
200 次查看(过去 30 天)
显示 更早的评论
I have a MxN matrix made of strings and I would like to convert it into a table because I need to have a timetable object in the end. My variable is a 720x2 strings, the first column contains the timestamp and the second contains a integer value.
This is an example of a row:
19/12/2017 00:00:00 116
I have tried using array2table and cell2table but I was not able to succeed.
I created a workaround, which is to write a file and then read it with readtable, but this way is definitely not immediate.
Thanks in advance, Edoardo
0 个评论
回答(2 个)
Julia Antoniou
2018-1-26
Hi Edoardo,
I believe you could accomplish the output you are describing with the following commands (with "matrix" being your matrix of strings):
>> Dates = matrix(:,1);
>> Data = matrix(:,2);
>> T = table(Dates,Data)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!