Error using odearguments (line 93) MEE342ODE must return a column vector.

7 visualizaciones (últimos 30 días)
function v_dot = MEE342ODE(t,v)
weight = 2100; %lbs
u = .7; %Coefficient of friction dry asphalt
cd = .38; %Drag Coefficient
cA = 6.96425; %ft^2 Drag area
p = 6.96425; %slug/ft^3 Density of air
Gr = 3; %Gear Ratio
Dr = 4.1; %Final Drive Ratio
rw = 11.37; %in Wheel Radius
w = linspace(1000,7000);
v = (w*rw/(Gr*Dr))*(60/63360);
% w = v*Gr*Dr*(63360/60)/rw;
Te = (-4.35657136262279e-13)*(w.^4)+(7.11138462292955e-09)*(w.^3)+(-4.34448497523093e-05)*(w.^2)+(0.122677685609034)*w+(-34.9042968448629);
Fr = u*weight; %lb Friction Force
Fd = .5*(v*(5280/60)).^2*p*cd*cA; %lb Drag Force
Ft = Te*Gr*Dr/rw; %lb Traction Force
v_dot = Ft-Fr-Fd;
end
The initial condition for the ODE is v(0)=0 Then in the command window:
tspan=[ 0 20];
x0=[0 0];
[tout,vout] = ode45(@MEE342ODE,tspan,x0)
I am getting the errors
Error using odearguments (line 93) MEE342ODE must return a column vector.
Error in ode45 (line 115) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
  2 comentarios
Michael Vietz
Michael Vietz el 18 de Abr. de 2018
I think that the problem is with the line w=linspace...
What I wanted to do was make Te a function of v but I had it as a function of w and w as a function of v
How can I make Te a function of v?
Walter Roberson
Walter Roberson el 18 de Abr. de 2018
I am not familiar with the equations involved.
I am not clear as to why you commented out
w = v*Gr*Dr*(63360/60)/rw
? It looks plausible that you just want that line without having used the linspace or having overwritten v.

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 18 de Abr. de 2018

You are ignoring the input v and its size, in favor of computing

v = (w*rw/(Gr*Dr))*(60/63360);

since w is a row vector (of length 100), v is going to be assigned to be a row vector.

With v being a row vector,

Fd = .5*(v*(5280/60)).^2*p*cd*cA; %lb Drag Force 

is going to be a row vector, so

 v_dot = Ft-Fr-Fd;

is going to be a row vector (of length 100).

However, the output from the ode function must be a column vector, never a row vector. And the size of the column vector must be the same as the size of the input v, which in this case is going to be the same size as x0 which is length 2.


Marcel Jiokeng
Marcel Jiokeng el 14 de Mayo de 2022
You should initialize v_dot in the function MEE342ODE(t,v) as it follows:
function v_dot = MEE342ODE(t,v)
v_dot = zeros(length(w),1);
....
....
....
v_dot = Ft-Fr-Fd;
end

Categorías

Más información sobre Ordinary Differential Equations 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