math question error with the format

1 view (last 30 days)
Dena Al-Kolak
Dena Al-Kolak on 8 Sep 2020
Answered: Geoff Hayes on 8 Sep 2020
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));

Answers (1)

Geoff Hayes
Geoff Hayes on 8 Sep 2020
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);

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!