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

 Respuesta aceptada

Star Strider
Star Strider el 21 de Feb. de 2018

1 voto

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 comentarios

Claire Hollow
Claire Hollow el 21 de Feb. de 2018
Thank you!
Star Strider
Star Strider el 21 de Feb. de 2018
As always, my pleasure!
If my Answer helped you solve your problem, please Accept it!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 21 de Feb. de 2018

Comentada:

el 21 de Feb. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by