Error using odearguments (line 93) MEE342ODE must return a column vector.
Afficher commentaires plus anciens
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 commentaires
Michael Vietz
le 18 Avr 2018
Walter Roberson
le 18 Avr 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.
Réponses (2)
Walter Roberson
le 18 Avr 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
le 14 Mai 2022
0 votes
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
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!