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

53 views (last 30 days)
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 Comment
Derek Paul
Derek Paul on 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')

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 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])

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!