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

47 Ansichten (letzte 30 Tage)
Derek Paul
Derek Paul am 9 Mär. 2017
Kommentiert: Star Strider am 9 Mär. 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 Kommentar
Derek Paul
Derek Paul am 9 Mär. 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')

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 9 Mär. 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])

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by