I keep getting an error message on this code, I dont know what the problem is. Keeps saying the expression is invalid

3 visualizaciones (últimos 30 días)
>>t = [0:10];
>>v1 = @t (2cos(t)-sin(t))*25*exp(-t);
>>plot(t,v1);

Respuesta aceptada

Star Strider
Star Strider el 16 de Nov. de 2018
Editada: Star Strider el 16 de Nov. de 2018
You need to:
  1. Put parentheses around the ‘t’ after the ‘@’ operator;
  2. use element-wise operations in your ‘v1’ anonymous function;
  3. call ‘v1’ as a function in your plot call.
Try this:
t = [0:10];
v1 = @(t) (2*cos(t)-sin(t))*25.*exp(-t);
plot(t,v1(t));
EDIT —
Also, you need to provide operators (such as ‘*’ and ‘.*’), since MATLAB does not recognise implied multiplication.

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by