combine cell and multidemensional matrix

1 view (last 30 days)
matla6123
matla6123 on 5 Apr 2017
Commented: matla6123 on 5 Apr 2017
Hi. I have a 5x1 cell with names in it ("names") and a 5x1 cell with usage numbers in it ("usage"). Within the "usage" cells are yx4 double values that all differ in length as different time periods are covered. i.e. if I open the first cell within "usage" it is 77x4, the second cell is 140x4, the third 79x4... like so...
Usage
77x4 double
140x4 double
79x4 double
77x4 double
52x4 double
Names
John
Jim
Sam
Tim
Tom
I am trying to make a matrix that has lists of all the values within "usage", but with the name next to each observation. Is there a simple way to achieve this?
  4 Comments
James Tursa
James Tursa on 5 Apr 2017
You can't combine numeric and character data in a double matrix. For that you would need a cell array or a table. E.g.,
result(1,1) = {[1 2 3 4],'John'}
result(2,1) = {[5 6 7 8],'John'}
:
etc
In other words, the first column of the cell array are the rows of your Usage matrices and the second column of the cell array would be the names. Is that acceptable?

Sign in to comment.

Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!