How to plot f: y=e^-x.sin^2x function in matlab?

조회 수: 27 (최근 30일)
Lenka Labikova
Lenka Labikova 2020년 11월 17일
댓글: Lenka Labikova 2020년 11월 18일
f: y=e^-x.sin^2x
Please help my computer gives errors and I don't know how to fix them.

채택된 답변

Setsuna Yuuki.
Setsuna Yuuki. 2020년 11월 17일
편집: Setsuna Yuuki. 2020년 11월 17일
You should try this
x = 0:1e-3:10
y=exp(-x).*sin(x).^2;
plot(x,y)

추가 답변 (1개)

Adam Danz
Adam Danz 2020년 11월 17일
편집: Adam Danz 2020년 11월 17일
Errors to fix (numbers refer to the characters above the numbers)
f: y=e^-x.sin^2x
% 1 2 34 5
  1. f: is not valid matlab syntax. You mean f=
  2. if e is a variable, this is OK but if you're looking for exponent, use exp(-x)
  3. x.sin is not valid matlab syntax. If you want multiplication, use x*sin (see next point)
  4. if 'sin' is a variable, then sin^2 is ok but it's a horrible variable name. If you want to use the sin function, use sin(__)
  5. 2x is not valid matlab syntax. Use 2*x if x is a scalar or 2.*x if x is an array. Or, sin(x)^2

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by