这是
该问题 ,
该问题和
该问题的重复部分,但是这些解决方案不起作用,所以我要问我。
我有一组本地定义的类,我想将其分配给多个单独的变量。此模式不起作用:
%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. 因为temp是一个单元格,所以我的2x1数组位于一个单元格中,而不是2x1单元格数组,而每个原始数组中的每个元素只有一个元素。
有任何想法吗?
回答:
您应该使用函数
NUM2CELL而不是函数
MAT2CELL ,以便将数组a每个元素放置在单元格数组temp的单独单元格中。
仅使用一个输入使用
MAT2CELL等同于执行temp = {a}; ,在我的MATLAB(R2009a)版本中,我实际上收到了以下警告:
>> temp = mat2cell(a); Warning: Single input behavior is obsolete and will be removed in a future release of MATLAB. Use C={X} instead. > In mat2cell at 54
更多&回答...