math question error with the format

1 visualizzazione (ultimi 30 giorni)
Dena Al-Kolak
Dena Al-Kolak il 8 Set 2020
Risposto: Geoff Hayes il 8 Set 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));

Risposte (1)

Geoff Hayes
Geoff Hayes il 8 Set 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);

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by