Is it possible to Join two dataset in malab? I imported a MATLAB file into MATLAB as a table and I have another set of data in form of an array in a separate variable .
2 次查看(过去 30 天)
显示 更早的评论
Is it possible to Join two dataset in malab? I imported a MATLAB file into MATLAB as a table and I have another set of data in form of an array in a separate variable. Please How do I merg the data to Have them both in one table? Thanks
0 个评论
回答(1 个)
Voss
2022-5-6
"How do I merge the data to have them both in one table?"
It depends on how what's in the array corresponds to what's in the table.
If: (1) the table has the same number of variables as the array has columns, and (2) all variables in the table are column vectors, and (3) you want to add the array to the end of the table, and (4) each variable in the table should match with the corresponding column of the array (i.e., they're in the same order), then it's pretty easy to do:
one_table = table([1;2;3],[4;5;6],[7;8;9])
separate_array = 10*magic(3)
separate_table = array2table(separate_array,'VariableNames',one_table.Properties.VariableNames);
final_table = [one_table; separate_table]
But I had to make 4 assumptions about the situation and your objective. If any of those assumptions are incorrect, then you'll have to do something else. The actual situation may be almost as easy to deal with as this simple case, or it may be much more difficult or impossible to achieve your objective.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!