Reputation: 179
I want to add to my table a column with numerical vectors of different length. Is that possible?
I really want to keep this data in the same table with the rest.
I'm trying to add column 'f'. Example:
A =
id name length f
1 'A' 80 [8 , 9 , 10]
2 'B' 100 [1]
3 'C' 5 [10, 500, -1, 2, 3, 4]
etc.
I might end up creating a large, NaN filled vector for each row, and replace them with the values I need, but that is a very ugly solution.
Thank you!
Upvotes: 2
Views: 654
Reputation: 5177
Assume f = {8:10; 1; [10, 500, -1, 2:4]};
, then
A = table(f);
should give you what you need. Or, if A
is already defined, A.f = f
.
Note that when accessing the data you have to use cell indexing to retrieve a vector of doubles, for example A.f{2}
will return 1
.
Upvotes: 2