矢量开箱八度 [英] vector unpacking for octave
问题描述
八度(/matlab)用于处理多个返回值的符号
Octave(/matlab)'s notation for handling multiple return values
[a, b] = f(x)
建议f(x)返回的值在某种行向量中,并且Octave支持向量拆包(如Python的元组拆包).
suggests that the values returned by f(x) are in a sort of row vector and that Octave supports vector unpacking (like Python's tuple-unpacking).
我放的时候
[a, b] = [1, 2]
我知道
错误:常量表达式的输出参数数量无效
error: invalid number of output arguments for constant expression
八度音程支持向量解压缩吗?
Does octave support vector-unpacking?
如果是这样,正确的表示法是什么?
If so, what's the proper notation?
我在文档中找不到任何内容
I can't find anything in the documentation
推荐答案
我没有Octave可以测试,但是在MATLAB中,您可以解压缩"单元格数组.
I don't have Octave to test, but in MATLAB you can "unpack" cell arrays.
x = {1 2};
[x1,x2] = x{:}
x1 =
1
x2 =
2
您可以将数值矢量转换为x = num2cell([1 2]);
的单元格数组.
You can convert numerical vector to a cell array as x = num2cell([1 2]);
.
我必须补充一点,这适用于从7.0版开始的MATLAB.对于早期版本,您必须使用 DEAL 函数.
I have to add that this works for MATLAB starting from version 7.0. For earlier version you have to use DEAL function.
这篇关于矢量开箱八度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!