Borrar filtros
Borrar filtros

i want to draw a graph

2 visualizaciones (últimos 30 días)
Ann Lee
Ann Lee el 29 de Abr. de 2022
Comentada: Voss el 29 de Abr. de 2022
i want to draw a graph on just command window.
f(x)=(exp(x).*sin(x)+(x./exp(x))
on 0<=x<=2*pi
but i got error! how i fix ?
>> f=@(x)(exp(x).*sin(x)+(x./exp(x))
x=linspace(0,2*pi,200);
error: parse error:
anonymous function bodies must be single expressions
>>> x=linspace(0,2*pi,200);
^
>>

Respuesta aceptada

Voss
Voss el 29 de Abr. de 2022
You are missing a close parenthesis
f=@(x)(exp(x).*sin(x)+(x./exp(x))
% ^ no matching close parenthesis for this
That open parenthesis is not necessary, so you can remove it:
f=@(x)exp(x).*sin(x)+(x./exp(x))
or add a close parenthesis on the end of the line:
f=@(x)(exp(x).*sin(x)+(x./exp(x)))
  2 comentarios
Ann Lee
Ann Lee el 29 de Abr. de 2022
oh my... thank you!!
Voss
Voss el 29 de Abr. de 2022
You're welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements 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