Clear Filters
Clear Filters

i want to draw a graph

2 views (last 30 days)
Ann Lee
Ann Lee on 29 Apr 2022
Commented: Voss on 29 Apr 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);
^
>>

Accepted Answer

Voss
Voss on 29 Apr 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 Comments
Ann Lee
Ann Lee on 29 Apr 2022
oh my... thank you!!
Voss
Voss on 29 Apr 2022
You're welcome!

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!