Mostrar comentarios más antiguos
Hi,
I have
t=0:0.01:10
x=a*t
y=sin(x)
and a has two values a=2, a=3
I want to plot (x, y) with two values of a in the same loop. Thanks in advance
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 3 de Feb. de 2012
t = 0 : 0.01 : 10
for a = 2 : 3
x = a .* t;
y = sin(x);
plot(x, y);
hold on % <---- THIS
end
Which is the same solution you were told in your two previous questions on the same topic.
3 comentarios
zina ben
el 3 de Feb. de 2012
Walter Roberson
el 3 de Feb. de 2012
If you have a vector of inputs stored in "a", then
t = 0 : 0.01 : 10;
for thisa = a
x = thisa .* t;
y = sin(x);
plot(x, y);
hold on % <---- THIS
end
zina ben
el 3 de Feb. de 2012
Categorías
Más información sobre Graphics Performance en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!