Second Order ODE Error (Error in ode45 (line 115))

Despite my best attempts to debug this small bit of code, I can't seem to find a solution for the error that I am receiving.
Are my ode45 parameters in the wrong form?
This is all one file:
clear all
%-----------------------------
xo = [1; 0.1];
tspan = [0 20];
[t,x]=ode45('f',tspan,xo);
plot(t,x(:,1));
%-----------------------------
function v = f(t,x)
m = 10; k = 25;
alpha = 250;
Fo = 150;
w = sqrt(k/m);
ceq = sqrt(q*m*alpha*Fo/m/3/pi);
v =[x(2); x(1).*-k/m+ x(2).*-ceq/m + Fo/m*cos(w*t)];
end
%-----------------------------
Errors Output:
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in Chase_Harmon_HW_6_ME_3220_003_Extra_Credit_Problem_3 (line 5)
[t,x]=ode45('v',tspan,xo);

Respuestas (1)

KALYAN ACHARJYA
KALYAN ACHARJYA el 4 de Abr. de 2019
Editada: KALYAN ACHARJYA el 4 de Abr. de 2019
In the function file following line q is not defined
ceq = sqrt(q*m*alpha*Fo/m/3/pi);

2 comentarios

Chase Harmon
Chase Harmon el 4 de Abr. de 2019
I can't believe I missed that, it's supposed to be just 8...
Thank you so much! It worked.
KALYAN ACHARJYA
KALYAN ACHARJYA el 4 de Abr. de 2019
Editada: KALYAN ACHARJYA el 4 de Abr. de 2019
Welcome!

Iniciar sesión para comentar.

Productos

Versión

R2018a

Etiquetas

Preguntada:

el 4 de Abr. de 2019

Editada:

el 4 de Abr. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by