MATLAB Answers

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

212 views (last 30 days)
Derek Paul
Derek Paul on 9 Mar 2017
Commented: Star Strider 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')

  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])

Sign in to answer this question.

Tags