Reputation: 1521
I have a cell array C looks like:
start end
------- --------
a b
c d
d a
I need to generate two arrays s=[a,c,d] and t=[b,d,a] from C.
Can you tell me how I can do it in Matlab?
Upvotes: 0
Views: 38
Reputation: 65460
If you have a cell array you can simply grab each column and convert to an array using cellmat
A = cellmat(C(:,1));
B = cellmat(C(:,2));
If the contents of each cell element is non-scalar, you'll need to leave them as a cell
, so you'll want to simply use ()
indexing
A = C(:,1);
B = C(:,2);
However, it looks like you actually have a table
in which case you can reference the columns directly
A = C.start;
B = C.end;
Upvotes: 1