how can I plot this exponential function?

hi, I have the following function g with the values of x
x = linspace(-2,2)
G = @(x) exp(x) .* (x <= 0) + sin(2*pi*x)./max(x,realmin) .* (x>0);
I tried to plot G using
plot(G,x)
but I am getting error. How can I plot G?

 Respuesta aceptada

Star Strider
Star Strider el 9 de Abr. de 2018
Since ‘G’ is a function handle, you cannot plot it.
You need to call it as a function and plot its output, so plot it either as:
plot(G(x), x)
or:
plot(x, G(x))
depending on what you want.

2 comentarios

rohail khan
rohail khan el 9 de Abr. de 2018
thank you so much Star
Star Strider
Star Strider el 9 de Abr. de 2018
As always, my pleasure.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Labels and Styling en Centro de ayuda y File Exchange.

Preguntada:

el 9 de Abr. de 2018

Comentada:

el 9 de Abr. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by