Octave Basics: How to Assign Variables from a Vector

Maybe I'm spoiled by Python, but Octave allows you to assign variable values โ€‹โ€‹directly from a vector? That is, doing something like

a,b,c=[5,6,7] 

will lead to a=5, b=6, c=7 . I tried many combinations of writing the expression above, but so far have failed ...

+6
source share
1 answer

This can be done by building an array of cells using "{...}" and converting it to a comma-separated list through "{:}":

 [abc] = {5 6 7}{:} a = 5 b = 6 c = 7 
+5
source

Source: https://habr.com/ru/post/911859/


All Articles