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

47 visualizaciones (últimos 30 días)
Derek Paul
Derek Paul el 9 de Mzo. de 2017
Comentada: Star Strider el 9 de Mzo. de 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 comentario
Derek Paul
Derek Paul el 9 de Mzo. de 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')

Iniciar sesión para comentar.

Respuestas (1)

Star Strider
Star Strider el 9 de Mzo. de 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])

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by