Create a results matrix/table
显示 更早的评论
I'd like to combine various types of data into a single matrix. The headers would be 'Date', 'File', 'Speed', 'Distance'.
Each time I process the data I have four data sets. Here's an example of an output:
Date1 = 'March 3 2015'
File1 = 'r8mar3speed1'
Speed1 = 44
Distance = 59
Date2 = 'March 3 2015'
File2 = 'r8mar3speed2'
Speed2 = 32
Distance2 = 63
Date3 = 'March 3 2015'
File3 = 'r8mar3speed3'
Speed3 = 34
Distance3 = 56
Date4 = 'March 3 2015'
File4 = 'r8mar3speed4'
Speed4 = 32
Distance4 = 58
I'd like to combine all of these into a single matrix with the dates in column 1, filenames in column 2, speeds in column3, and distances in column 4 but I'm having trouble because some data are strings.
回答(1 个)
Geoff Hayes
2015-3-14
T = table({Date1; Date2; Date3; Date4}, ...
{File1; File2; File3; File4}, ...
[Speed1; Speed2; Speed3; Speed4], ...
[Distance; Distance2; Distance3; Distance4], ...
'VariableNames', {'Date','File','Speed','Distance'})
Or use a cell array since you have different data types.
类别
在 帮助中心 和 File Exchange 中查找有关 Tables 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!