math question error with the format

1 Ansicht (letzte 30 Tage)
Dena Al-Kolak
Dena Al-Kolak am 8 Sep. 2020
Beantwortet: Geoff Hayes am 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));

Antworten (1)

Geoff Hayes
Geoff Hayes am 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);

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by