plotting several quadratic functions

5 vues (au cours des 30 derniers jours)
ahmed-wali
ahmed-wali le 15 Nov 2012
Réponse apportée : Dr le 18 Oct 2022
would like to plot 3 to 4 qaudratic functions (a*x^2+1) on the same coordinates by changing the value of a from -1:1:2. can i use the for loop for this? many thanks

Réponse acceptée

Grzegorz Knor
Grzegorz Knor le 15 Nov 2012
Yes, I think that it is good idea:
figure
hold all
x = linspace(0,1);
for a=-1:1:2
plot(x,a*x.^2+1)
end
hold off
legend('a=-1','a=0','a=1','a=2')
  1 commentaire
ahmed-wali
ahmed-wali le 17 Nov 2012
great many thanks

Connectez-vous pour commenter.

Plus de réponses (1)

Dr
Dr le 18 Oct 2022
figure
hold all
x = linspace(0,1);
for a=-1:1:2
plot(x,a*x.^2+1)
end
hold off
legend('a=-1','a=0','a=1','a=2')

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by