倍频程基础知识:如何从向量分配变量 [英] Octave basics: How to assign variables from a vector

查看:60
本文介绍了倍频程基础知识:如何从向量分配变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许我被Python宠坏了,但是Octave是否允许直接从向量分配变量的值?也就是说,做类似的事情

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]

将得到a=5, b=6, c=7. 我已经尝试过多种组合来编写上面的表达式,但是还没有运气...

will result with a=5, b=6, c=7. I have tried many combinations of writing the expression above, but no luck yet ...

推荐答案

这可以通过使用"{...}"构造一个单元格数组,然后通过"{:}"将其转换为逗号分隔的列表来完成:

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

这篇关于倍频程基础知识:如何从向量分配变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆