Problem with assigning elements of a class array to individual variables in MATLAB

Posted by Marc on Stack Overflow See other posts from Stack Overflow or by Marc
Published on 2010-06-14T14:42:10Z Indexed on 2010/06/15 16:22 UTC
Read the original article Hit count: 291

Filed under:
|
|
|

This is a bit of a duplicate of this question, this question, and this question, however those solutions don't work, so I'm asking mine.

I've got an array of locally defined classes and I'd like to assign it to multiple, individual variables. This pattern doesn't work:

%a is 2x1 of MyClass
temp = mat2cell(a);
[x,y] = temp{:};

%throws:
??? Insufficient number of outputs from right hand side of equal sign to satisfy assignment.

Because temp is a single cell, with my 2x1 array in one cell, rather than a 2x1 cell array with one element of each of my original array in one cell.

Any ideas?

© Stack Overflow or respective owner

Related posts about arrays

Related posts about matlab