简体   繁体   English

MATLAB从for循环创建数组

[英]MATLAB Create an array from a for loop

I have to create an array from the outputs of a for loop. 我必须从for循环的输出创建一个数组。 For example, if the for loop was: 例如,如果for循环为:

for i=[0.01, 0.02, 0.05]
    exp(i)
end

I should create an array such as 我应该创建一个数组,例如

[exp(0.01) exp(0.02) exp(0.03)]

How can I do that? 我怎样才能做到这一点? Thanks. 谢谢。

Almost like you did :-) 几乎像您一样:-)

V= [0.1 0.2 0.3]
R=exp(V)

Create a vector of values for which you want to compute a function and pass it as parameter. 创建要为其计算函数的值的向量,并将其作为参数传递。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM