0

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?

1
  • That looks like a table rather than a cell Commented Apr 11, 2017 at 18:48

1 Answer 1

1

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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.