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.

Answers (1)

Stanley - consider using a table as
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.

1 Comment

Unfortunately my version of Matlab doesn't have the table() function. I'm on R2013a, I believe it was implemented in R2013b.

Sign in to comment.

Categories

Asked:

on 13 Mar 2015

Commented:

on 17 Mar 2015

Community Treasure Hunt

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

Start Hunting!