![]() |
如何在MATLAB中进行多重分配?
这是我要寻找的示例:
>> foo = [88, 12]; >> [x, y] = foo; 我[I]希望[/I]这样的事情以后: >> 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编制索引? [B]回答:[/B] 您根本不需要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 [url=https://stackoverflow.com/questions/2337126]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 07:05。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.