- #1
mmmann1
- 1
- 0
Please help me recognize what is wrong with this professor supplied code...
clear all
options=odeset('events', @events_passing)
[t,z]=ode45(@passing,[0,10],[0,50*88/60],options)
plot(t,z)
function [value,isterminal,direction]=events_passing(t,z)
value=z(2)-88;
isterminal=1;
direction=0;
end
%Gillespie Data Page32
function torque=engine_gillespie(omega)
torque_coeff =[-1.5752e-006 7.9768e-004 1.8454e-001 9.9834e+001];
torque=polyval(torque_coeff,omega);
function f=passing(t,z)
f=zeros(2,1);
x=z(1);
v=z(2);
g=32.2;
M=2500/g;
I_e=0.8/12;
I_t=0.5/12;
I_d=1.2/12;
I_w=11/12;
N_t=1.36;
N_f=2.92;
N_tf=N_t*N_f;
Re=12.59/12;
rho=0.00236;
c_d=0.32;
A=20;
f0=0.015;
M_r=(I_e+I_t)*N_tf^2/Re^2+I_d*N_f^2/Re^2+4*I_w/Re^2;
M_equivalent=M+M_r;
dvdt=(engine_gillespie(v*N_tf/Re)*N_tf/Re-f0*M*g-0.5*rho*A*c_d*v^2-M*g*sin(atan(.02)))/M_equivalent;
f(1)=v;
f(2)=dvdt;
clear all
options=odeset('events', @events_passing)
[t,z]=ode45(@passing,[0,10],[0,50*88/60],options)
plot(t,z)
function [value,isterminal,direction]=events_passing(t,z)
value=z(2)-88;
isterminal=1;
direction=0;
end
%Gillespie Data Page32
function torque=engine_gillespie(omega)
torque_coeff =[-1.5752e-006 7.9768e-004 1.8454e-001 9.9834e+001];
torque=polyval(torque_coeff,omega);
function f=passing(t,z)
f=zeros(2,1);
x=z(1);
v=z(2);
g=32.2;
M=2500/g;
I_e=0.8/12;
I_t=0.5/12;
I_d=1.2/12;
I_w=11/12;
N_t=1.36;
N_f=2.92;
N_tf=N_t*N_f;
Re=12.59/12;
rho=0.00236;
c_d=0.32;
A=20;
f0=0.015;
M_r=(I_e+I_t)*N_tf^2/Re^2+I_d*N_f^2/Re^2+4*I_w/Re^2;
M_equivalent=M+M_r;
dvdt=(engine_gillespie(v*N_tf/Re)*N_tf/Re-f0*M*g-0.5*rho*A*c_d*v^2-M*g*sin(atan(.02)))/M_equivalent;
f(1)=v;
f(2)=dvdt;