How do you show the negative x values on the graph?

47 vues (au cours des 30 derniers jours)
Derek Paul
Derek Paul le 9 Mar 2017
Commenté : Star Strider le 9 Mar 2017
x = linspace(0,7.999999999,8)
y = exp(-x) + exp(-2*x)
y1 = (exp(x)/6 + exp(-x) + exp(-2*x))
scatter(x,y,'r','filled')
hold on
plot(x,y1,'b')
title('Question 2')
legend('homogeneous','inhomogeneous')
  1 commentaire
Derek Paul
Derek Paul le 9 Mar 2017
x = linspace(0,7.999999999,8)
y = exp(-x) + exp(-2*x)
y1 = (exp(x)/6 + exp(-x) + exp(-2*x))
scatter(x,y,'r','filled')
hold on
plot(x,y1,'b')
title('Question 2')
legend('homogeneous','inhomogeneous')

Connectez-vous pour commenter.

Réponses (1)

Star Strider
Star Strider le 9 Mar 2017
Since you defined ‘x’ as:
x = linspace(0,7.999999999,8);
you do not have any negative x-values to plot. If you want to extend the x-axis to go from -1 to +8 for example, somewhere after your scatter and plot calls, add this line:
set(gca, 'XLim',[-1 8])
  2 commentaires
Derek Paul
Derek Paul le 9 Mar 2017
Ok thank you
Star Strider
Star Strider le 9 Mar 2017
My pleasure.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by