math question error with the format

조회 수: 1 (최근 30일)
Dena Al-Kolak
Dena Al-Kolak 2020년 9월 8일
답변: Geoff Hayes 2020년 9월 8일
I am getting an error when I use this function
x =inline('sin(2*pi*1*t).(2*exp)(-.1*t)','t');
Is there a different way I should type it? This is my first time using matlab.
Error using inlineeval (line 14)
Error in inline expression ==> sin(2*pi*1*t).(2*exp)(-.1*t)
Not enough input arguments.
Error in inline/subsref (line 23)
INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);
Error in Untitled (line 3)
plot(t,x(t));

답변 (1개)

Geoff Hayes
Geoff Hayes 2020년 9월 8일
Dena - I suspect the error is due to the use of exp where you are not providing any inputs to this function. The code should probably be written as
x =inline('sin(2*pi*1*t).*(2*exp(-.1*t))','t');
instead (note the change of the brackets and the replacing of '.' with '.*' between the two expressions - is this correct?). But do you need to use an inline function? Could the recommended anonymous function be used as an alternative?
>> f = @(t)sin(2*pi*1*t).*(2*exp(-.1*t));
>> t = 1:10;
>> result = f(t);

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by