What I'm looking to do is create a script that will put the values between 1 and 50 by increments of 0.5 in a Matrix after they go through the equation 331+(0.6*k). This is what I have so far but it only gives me one value and I'm stumped on how to do a matrix with all of the values:
for k=0:0.5:50;
wave=331+(0.6*k);
end

 采纳的回答

You would have to set up a separate index variable to do that in a for loop:
k = 0:0.5:50;
for kk = 1:numel(k)
wave(kk) = 331+(0.6*k(kk));
end
However MATLAB can do that calculation in one line, without the explicit loop:
k = 0:0.5:50;
wave = 331+(0.6*k);

2 个评论

As always, my pleasure!
If my Answer helped you solve your problem, please Accept it!

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by