这是我要寻找的示例:
>> foo = [88, 12]; >> [x, y] = foo; 我
希望这样的事情以后:
>> x x = 88 >> y y = 12 但是相反,我得到如下错误:
??? Too many output arguments. 我以为deal()可以做到,但它似乎只适用于单元格。
>> [x, y] = deal(foo{:}); ??? Cell contents reference from a non-cell array object. 我该如何解决我的问题?如果要分别处理它们,是否必须不断按1和2编制索引?
回答:
您根本不需要deal (编辑:对于Matlab 7.0或更高版本),例如,您不需要mat2cell ;您可以将num2cell与其他参数一起使用:
foo = [88, 12]; fooCell = num2cell(foo); [xy]=fooCell{:} x = 88 y = 12 如果您出于其他原因想要使用deal ,则可以:
foo = [88, 12]; fooCell = num2cell(foo); [xy]=deal(fooCell{:}) x = 88 y = 12
更多&回答...