Plot for different value of a

x = [-2:0.1:2];
z=x.*(a-x^2);
plot(x,z)
I want to plot(x, z) for four values of a = .5, 1, 1.3, 1.95. How to code it without writing same programme for different a four times.

 Respuesta aceptada

John Petersen
John Petersen el 18 de Dic. de 2012
Editada: John Petersen el 18 de Dic. de 2012

6 votos

x = [-2:0.1:2];
a = [.5, 1, 1.3, 1.95];
figure;
for i=1:length(a)
z = x.*(a(i)-x.^2);
plot(x,z);hold on;
end

1 comentario

ABDUL RAZAK BIN NAINA MOHAMED
ABDUL RAZAK BIN NAINA MOHAMED el 29 de Sept. de 2019
how to give different color for each plot for this case

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 18 de Dic. de 2012

Comentada:

el 29 de Sept. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by