Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
grex91

Posts: 2
Registered: 5/1/13
Ode45 error
Posted: May 1, 2013 5:46 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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]');



%% Task 6

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);
[t_vec,Y]=ode45(@(t,y) equ_task6(t,y,m,Ig,l,lf,lr,h,cf,cr,df,dr,rho,Af,cd,c_Lf,c_Lr,v_start,F_bf,k,k_b,F_bf_max),[0 t_max],zeros(1,6),options);


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...

function dy= equ_task6(t,y,m,Ig,l,lf,lr,h,cf,cr,df,dr,rho,Af,cd,c_Lf,c_Lr,v_start,F_bf,k,k_b,F_bf_max)

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
Read Ode45 error
grex91
5/1/13
Read Re: Ode45 error
Steven Lord
5/1/13
Read Re: Ode45 error
grex91

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.