how to plot this ?

syms x;
y=exp(-x).*sin(x);
plot(x,y);
hey, i want to plot this but for reaon I can't.. I didn't find any answer in previous questions.
can someone tell me where I am wrong ?

Respuestas (1)

Stephan
Stephan el 21 de Oct. de 2020

1 voto

syms x;
y=exp(-x).*sin(x);
fplot(x,y);

4 comentarios

Tomer Segev
Tomer Segev el 21 de Oct. de 2020
why are you using the fplot ?
Stephan
Stephan el 21 de Oct. de 2020
fplot plots expressions or functions - this is what you have done here. To use plot, you would need to have vectors containing values to plot. For example:
fun = @(x) exp(-x).*sin(x);
fplot(fun)
works - but
fun = @(x) exp(-x).*sin(x);
plot(y)
gives an error. If you calculate values from the function, it will work using plot:
fun = @(x) exp(-x).*sin(x);
x = linspace(-5,5);
y = fun(x);
plot(x,y)
This is the difference in both commands.
Stephan
Stephan el 21 de Oct. de 2020
BTW: Did you notice that you can accept and/or vote for useful answers?
Tomer Segev
Tomer Segev el 21 de Oct. de 2020
OK, that's great! thank you!

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 21 de Oct. de 2020

Comentada:

el 21 de Oct. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by