Vector unpacking for octave

Octave notation (/ matlab) for handling multiple return values

[a, b] = f(x)

assumes that the values ​​returned by f (x) are a kind of line vector and that Octave supports vector unpacking (e.g. Pupon tuple unpacking).

But when I put

[a, b] = [1, 2]

I get

error: invalid number of output arguments for constant expression

Does vector octave decompression support?

If so, what is the correct notation?

I can not find anything in the documentation

+5
source share
1 answer

I don't have an Octave check, but in MATLAB you can “unzip” cell arrays.

x = {1 2};
[x1,x2] = x{:}

x1 =
     1
x2 =
     2

You can convert a numerical vector to an array of cells like x = num2cell([1 2]);.

, MATLAB, 7.0. DEAL.

+3

All Articles