필터 지우기
필터 지우기

I keep getting an error message on this code, I dont know what the problem is. Keeps saying the expression is invalid

조회 수: 1 (최근 30일)
>>t = [0:10];
>>v1 = @t (2cos(t)-sin(t))*25*exp(-t);
>>plot(t,v1);

채택된 답변

Star Strider
Star Strider 2018년 11월 16일
편집: Star Strider 2018년 11월 16일
You need to:
  1. Put parentheses around the ‘t’ after the ‘@’ operator;
  2. use element-wise operations in your ‘v1’ anonymous function;
  3. call ‘v1’ as a function in your plot call.
Try this:
t = [0:10];
v1 = @(t) (2*cos(t)-sin(t))*25.*exp(-t);
plot(t,v1(t));
EDIT —
Also, you need to provide operators (such as ‘*’ and ‘.*’), since MATLAB does not recognise implied multiplication.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by