有没有像交易()正常MATLAB阵列什么? [英] Is there anything like deal() for normal MATLAB arrays?

查看:133
本文介绍了有没有像交易()正常MATLAB阵列什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  我该怎么做多重分配在MATLAB?

当使用电池阵列处理,我可以使用交易()函数分配细胞输出变量,如:

When dealing with cell arrays, I can use the deal() function to assign cells to output variables, such as:

[a, b, c] = deal(myCell{:});

或者只是:

[a, b, c] = myCell{:};

我愿做同样的事,一个简单的数组,如:

I would like to do the same thing for a simple array, such as:

myArray = [1, 2, 3];
[a, b, c] = deal(myArray(:));

但是,这并不正常工作。什么是另类?

But this doesn't work. What's the alternative?

推荐答案

一种选择是你的数组转换为一个单元阵列首先使用的NUM2CELL

One option is to convert your array to a cell array first using NUM2CELL:

myArray = [1, 2, 3];
cArray = num2cell(myArray);
[a, b, c] = cArray{:};

当你注意,你甚至不需要使用 DEAL 分发单元格内容。

这篇关于有没有像交易()正常MATLAB阵列什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆