Octave basics: How to assign variables from a vector

久未见 提交于 2019-12-23 09:31:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!