Azzera filtri
Azzera filtri

i want to draw a graph

2 visualizzazioni (ultimi 30 giorni)
Ann Lee
Ann Lee il 29 Apr 2022
Commentato: Voss il 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);
^
>>

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by