Trouble solving second order ODE
Mostra commenti meno recenti
Hello everyone, I am trying to convert the following Simulink simulation of a braking vehicle into Matlab code using the ode45 solver. But somehow the outcome is much diffrent from what i am expecting it to be.

The scope with two inputs shows the velocity of the vehicle (blue) and the wheels (yellow). The integration for the wheel velocity is limited downwards to 0. So the wheel locks up.

My function (shortend)
function ABL = ohneABS_Fkt(t, Z_V);
global rR J_R Mb A cw rhoL F_N m dt
global c1 c2 c3
%% Time
t %Simulationtime
%% initial Conditions
xF_p = Z_V(3);
xF_pp = 0;
phi_p = Z_V(4);
phi_pp = 0;
%% phi_pp, phi_p und vR ; pp = second derivation; p = first derivation
% Wheel
vR = phi_p*rR;
Lambda = (xF_p-vR)/xF_p;
my = c1*(1-exp(-c2*Lambda))-c3*Lambda;
F_R = F_N*my;
phi_pp = (F_R*rR-Mb)/J_R; % This is the input into the integrator on the left in Simulink
%% xF_pp, xF_p
%Vehicle body
xF_pp = (-F_R)/m; % This is the Input into the first integrator on the right
ABL = [xF_p;
phi_p;
xF_pp;
phi_pp];
end
My program (shortend)
%Bremsung ohne ABS nach MuSdS
clear all
close all
clc
%% Parameter
global rR J_R Mb A cw rhoL F_N m dt
global c1 c2 c3
vF0 = 100/3.6; %m/s #100/3.6
rR = 0.3; %Reifenradius in m
J_R = 0.8; %kgm^2 Traegheitsmoment des Reifens
g = 9.81; %m/s^2 Erdbeschleunigung
m = 1500; %kg Teilmasse am Rad
Mb = 5335; %Maximales Bremsmoment [Nm] #Wert aus MuSdS 5335
A = 2; %m^2 Stirnflaeche
cw = 0.3; %Luftwiderstandsbeiwert
rhoL = 1.2; %kg/m^3 Luftdichte
F_g = m*g; %Gewichtkraft [N]
F_N = 1.5 * F_g; %Normalkraft = Gewichtkraft + Nickmoment
% Reifenmodell
c1 = 0.86;
c2 = 33.82;
c3 = 0.36;
% Simulationtime
tend = 4; %Simulationszeit
dt = 0.005; %Zeitschritt
%% Anfangsbedingungen
xF0 = 0;
vR0 = vF0;
wR0 = vR0/rR;
Start = [xF0;
0;
vF0;
wR0];
%% Berechnung
[t,Z_V] = ode45(@ohneABS_Fkt,[0:dt:tend],Start);
for k = 1:length(t)
vR(k) = Z_V(k,4)*rR;
end
figure
subplot(2,2,1)
plot(t,Z_V(:,1),'r'); hold on
plot(t,Z_V(:,2),'b');
legend('xF','phi');
xlabel('t [s]');
ylabel('distance [m]');
hold off
subplot(2,2,2)
plot(t,Z_V(:,3),'r',t,vR(:),'b');
legend('vF','vR');
xlabel('t [s]');
ylabel('velocity [m/s]');
The outcome of the Matlabprogram vF = vehicle velocity; vR = wheel velocity

So essentialy I'm having trouble solving the two coupled second order differential equations. The outcome in matlab should be the same as in simulink. Is there a way/ strategy to convert simulink models into Matlab? Does anybody see the flaw in my code?
Risposte (0)
Categorie
Scopri di più su General Applications in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!