i want to draw a graph

1 次查看(过去 30 天)
Ann Lee
Ann Lee 2022-4-29
评论: Voss 2022-4-29
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);
^
>>

采纳的回答

Voss
Voss 2022-4-29
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)))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by