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*(1exp(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)*(1k_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= llf; %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',1e3,'AbsTol',1e6);
[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*(1k_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_fF_b_rFd;
b2= Fd*hF_Lf*lf+F_Lr*lr+h(F_b_f+F_b_r)F_b_f*0.15*lfF_b_r*0.3*lr;
b3= F_Lf+F_Lr+F_b_f*0.15F_b_r*0.3;
M=[m 0 0; 0 Ig 0; 0 0 m];
A=[0 0 0 0 0 0; 0 0 lf*cflr*cr lf*dflr*dr (cf+cr) (df+dr); 0 0 ((lf^2)*cf+(lr^2)*cr) ((lf^2)*df+(lr^2)*dr) lf*cflr*cr lf*dflr*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!
