math question error with the format

1 visualización (últimos 30 días)
Dena Al-Kolak
Dena Al-Kolak el 8 de Sept. de 2020
Respondida: Geoff Hayes el 8 de Sept. de 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));

Respuestas (1)

Geoff Hayes
Geoff Hayes el 8 de Sept. de 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);

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by