问题
Maybe I'm spoiled by Python, but does Octave allows one to assign the values of variables directly from a vector? That is, doing something like
a,b,c=[5,6,7]
will result with a=5, b=6, c=7
.
I have tried many combinations of writing the expression above, but no luck yet ...
回答1:
This can be done by constructing a cell array with "{...}" and converting this to a comma separated list via "{:}":
[a b c] = {5 6 7}{:}
a = 5
b = 6
c = 7
来源:https://stackoverflow.com/questions/9908398/octave-basics-how-to-assign-variables-from-a-vector