Contents
function [sys,x0,str,ts] = SimpleVehicleSFunction(t,x,u,flag)
TireModel = TirePacejka();
TireModel.a0 = 1;
TireModel.a1 = 0;
TireModel.a2 = 800;
TireModel.a3 = 3000;
TireModel.a4 = 50;
TireModel.a5 = 0;
TireModel.a6 = 0;
TireModel.a7 = -1;
TireModel.a8 = 0;
TireModel.a9 = 0;
TireModel.a10 = 0;
TireModel.a11 = 0;
TireModel.a12 = 0;
TireModel.a13 = 0;
VehicleModel = VehicleSimpleNonlinear();
VehicleModel.mF0 = 700;
VehicleModel.mR0 = 600;
VehicleModel.IT = 10000;
VehicleModel.lT = 3.5;
VehicleModel.nF = 2;
VehicleModel.nR = 2;
VehicleModel.wT = 2;
VehicleModel.muy = .8;
VehicleModel.tire = TireModel;
switch flag,
case 0,
[sys,x0,str,ts]=mdlInitializeSizes();
case 1,
sys=mdlDerivatives(t,x,u,VehicleModel);
case 3,
sys=mdlOutputs(t,x,u,VehicleModel);
case { 2, 4, 9 },
sys = [];
otherwise
DAStudio.error('Simulink:blocks:unhandledFlag', num2str(flag));
end
function [sys,x0,str,ts]=mdlInitializeSizes()
sizes = simsizes;
sizes.NumContStates = 6;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 6;
sizes.NumInputs = 3;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
x0 = [0 0 0 20 0 0];
str = [];
ts = [0 0];
function sys = mdlDerivatives(t,x,u,vehicle)
vehicle.deltaf = u(1);
vehicle.Fxf = u(2);
vehicle.Fxr = u(3);
ModelFunction = @vehicle.Model;
sys = ModelFunction(t,x,0);
function sys=mdlOutputs(~,x,~,~)
sys = x;
[Home] [Template Simple Simulink]