Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Ode45 error
Replies: 2   Last Post: May 1, 2013 11:55 AM

 Messages: [ Previous | Next ]
 grex91 Posts: 2 Registered: 5/1/13
Ode45 error
Posted: May 1, 2013 5:46 AM

Ehi, i'm trying so solve a problem with ode45 but it gives me an error that i don't understand (i'm pretty new in matlab or any kind of programming).

here is the main code:
k= 20; %1/s
t= linspace(0,4,100);

for i=1:100

F_bf= inline('F_bf_max*(1-exp(-k*t))','t','k','F_bf_max');
F_bf_vector(i)=F_bf(t(i),k,F_bf_max);
F_br_vector(i)=F_bf_vector(i)*(1-k_b)/k_b;

end

figure
plot(t,F_bf_vector,'linewidth',2);
title('Braking force as function of time');
xlabel('Time [s]');
ylabel('Frontal braking force [N]');

m= 1100; %Kg
Ig= 1500; %Kg*m^2
l= 2.5; %m
lf= 1.1;%m
lr= l-lf; %m
h= 0.5; %m
cf= 10; %KN/m
cr= 10; %KN/m
df= 1.0; %KN*s/m
dr= 1.0; %KN*s/m
rho= 1.226; %Kg/m^3
Af= 2.15; %m^2
cd= 0.29;
c_Lf= 0.13;
c_Lr= 0.10;

t_max=4; %s
v_start= 100/3.6; %m/s

options= odeset('RelTol',1e-3,'AbsTol',1e-6);

x= Y(:,1)
x_dot= Y(:,2);
phi= Y(:,3);
phi_dot= Y(:,4);
z= Y(:,5);
z_dot= Y(:,2);

And here is the function, i think the problem is related to "b2" but i don't understand why...

x=y(1);
x_dot=y(2);
phi=y(3);
phi_dot=y(4);
z=y(5);
z_dot=y(6);

F_b_f=F_bf(t,k,F_bf_max);
F_b_r=F_b_f*(1-k_b)/k_b;

Fd= 0.5*rho*Af*cd*((y(2)+v_start)^2);
F_Lf= 0.5*rho*Af*c_Lf*((y(2)+v_start)^2);
F_Lr= 0.5*rho*Af*c_Lr*((y(2)+v_start)^2);

b1= -F_b_f-F_b_r-Fd;
b2= Fd*h-F_Lf*lf+F_Lr*lr+h(F_b_f+F_b_r)-F_b_f*0.15*lf-F_b_r*0.3*lr;
b3= F_Lf+F_Lr+F_b_f*0.15-F_b_r*0.3;

M=[m 0 0; 0 Ig 0; 0 0 m];
A=[0 0 0 0 0 0; 0 0 lf*cf-lr*cr lf*df-lr*dr -(cf+cr) -(df+dr); 0 0 -((lf^2)*cf+(lr^2)*cr) -((lf^2)*df+(lr^2)*dr) lf*cf-lr*cr lf*df-lr*dr];
B=[b1; b2; b3];

C=M\A;
D=M\B;

acc=C*y+D;

dy= zeros(6,1);
dy(1)= y(2);
dy(2)= acc(1);
dy(3)= y(4);
dy(4)= acc(2);
dy(5)= y(6);
dy(6)= acc(3);

Thanks for any help!

Date Subject Author
5/1/13 grex91
5/1/13 Steven Lord
5/1/13 grex91