File Exchange

image thumbnail

MATLAB and Simulink Racing Lounge: Vehicle Modeling

Simulink and Powertrain Blockset models for the Vehicle Modeling series


Updated 20 Jun 2018

View License

This entry contains files accompanying the MATLAB and Simulink Racing Lounge video "Vehicle Modeling, Part 1: Simulink"
[Video link:]
The entry also contains the models accompanying the MATLAB and Simulink Racing Lounge video "Vehicle Modeling, Part 2: Powertrain Blockset"
[Video Link:]
The Simulink models show how to represent vehicle dynamics and specific components using a power loss approach.
* A glider model shows how to model vehicle dynamics to obtain high level information about tractive force requirements for a given weight and drive cycle.
* A battery electric vehicle (BEV) model shows how to use a power loss approach to represent individual components, such as the electric motor.
* A combustion engine vehicle model is also included for additional reference.

The Powertrain Blockset models show how single blocks can represent component operation, e.g: battery, motor, engine, transmission, differential, etc. These models include a glider, a BEV, and a combustion engine vehicle.

Comments and Ratings (40)

Thank you for such a versatile model. I would like to cite this, can you please guide as to how I should go about doing it?

Thank you.

Hi Dinesh,

To answer your second question, it would be better if you could share the email with us on


Hi Dinesh,

The values are stored in the Simulink model workspace.
You may access it through Simulink toolbar -> View -> Model Explorer.
This link provides a bit more background:

In case you are still unable to find the data, drop an email to We will send you the screen shots via email.


Dinesh tej

Hii Christoph sir
I am not getting, should I add BEV model to that Existing 3D Animation or the Power train blocks which are available in the file exchange?

Dinesh tej

Hii Christoph sir
Can you Please tell me what is the Specifications of Battery, motor specifications and type of motor used here ?

Hi Deepa,

some thoughts about the question you asked on March 30:
That inclination angle is used by the GradeForce[N] block, which calculates a force based on massVeh*gravity*sin(inclinationAngle). By default, the sin function in MATLAB takes angles as radians. To operate in degrees, then use massVeh*gravity*sin(deg2rad(inclinationAngle))
The negative speed value means reverse motion. This would happen if resistive forces (like grade) act on the vehicle before the tractive force can dominate the vehicle motion.

Hope this helps,
Best, Christoph

Hi Dinesh Tej,

the model you are referring to is a simplified one. It takes into account the powertrain and the longitudinal dynamics. So e.g. lateral dynamics are entirely missing. It wouldn’t be very helpful to display this in 3D animation.

What you may want to do is the following.
1. Check out the Vehicle Dynamics Blockset including its examples. E.g. run this command >> vdynblksSceneCameraRayStart in the MATLAB Command Window. Thereby you get the 3D animation running.
2. Add the vehicle model features from this FileExchange submission to the model created in #1.

Hope this helps to get started.
Best, Christoph

Dinesh tej

How to add 3D animations to the your BEV model ?



Hi Christoph sir,
the inclination angle given is zero degrees in the modelling, when we change the angle to say 20 degrees the output velocity is getting started from -2.3 mph while the input is unchanged, can you please briefly describe what does that negative values interpret in the real time?

Hi Deepa, you may certainly give it an initial try using PID Tuner ( With respect to the vehicle model, the PID block is actually a (very simplified) representation of the vehicle. So you would want to tune it to mimick you actual vehicle. Same holds true for the driver. Via the PID block you can tune it to be more aggressive or relaxed. Best, Christoph


thank you Christoph sir.
And Can you please tell me how the PID constants are selected particularly for both driver glider(P-7500, I-1, D-0) and BEV system(P-250, I-1, D-0).

Hi Deepa, these are motor loss constants: k_c [s / kg m^2], ki [J], k_w [kg m^2]. In general, you could say that: P_loss = P_in - P_out. P_loss in our example is a function of p_in and is approximated by a quadratic equation with these constants: P_loss = C_0 + C_1 * P_in + C_2 * P_in^2. If you have test data about losses, I suggest you do your own regression / curve fitting to get the constants. If you don't have test data, you could start with an ideal (lossless) motor and estimate the impact of the error. Best, Christoph


Sir how to choose the constants like Kc, Ki, Kw etc. ?

Hi Yujie, I guess you are referring to the models of the physical modeling tutorial that we are mentioning in the video. Find them here: Hope this is what you are looking for. Best, Christoph

Yujie Hu

battery, motor, engine... models cannot be found in the zip file. Could you add them in? Thank you very much!

Hi Deepa Anand,
the drive cycle is stored in the Simulink model workspace.
You may access it through Simulink toolbar -> View -> Model Explorer.
This link provides a bit more background:
Best, Christoph


how I can access the drive cycle stored parameters?

Hi Josh,
good point! The data is accessible through the Simulink model workspace. See here a reference:
Hope that helps.
Best, Christoph

Hello, I'm confused how I can access the drive cycle and other similarly stored parameters. For instance, the Constant block contains DrCycles.US06. How do I access and view the data stored in US06? Normally I would look in the Matlab workspace but I don't see it.

salutations, je veux exploiter le modèle de véhicule électrique à batterie (BEV), mais je n'ai pas compris comment ils ont modelisé chaque bloc. est ce qu'il ya un ecrit explicatif de ce modele? merci.
Said Belhadj.

i dont have matlab 2018 latest version. I am using Matlab 2017 b Can you please export this to my version?


Thanks for sharing such nice model.
One minor note on engine rotational speed calculation in the conventional model (version 3.0):
inside the driveline subsystem, it is calculating omega by dividing Velocity [mph] by wheel radius [m], the velocity shall be converted from mph to mps before division.

Hi Vasudevan. If you are looking to convert a current model into an older version, we already have an answer on MATLAB Answers:
I would also encourage you to upgrade to the latest release.

I downloaded the models but when I open them, the Canvas interface shows me the next error:
"Failed to load library 'Driver_Glider_Library' "
Can anyone help ?

Hi, is it possible to release the files in an earlier version of MATLAB? Maybe r2015a? Thanks!

how can i run this models with matlab 2016 a version ? it gives me an error because this models were created with different version.

when I run simulation I get errors
Warning: Could not evaluate MaskDisplay commands of block 'PTB_BatteryElectricVehicle/Battery/Datasheet Battery':
Undefined function 'autoicon' for input arguments of type 'char'.

can anyone help??


Update model to R2018 and fixed minor bugs.

Updated models to R2017b and fixed minor bugs.

Added vehicle models that use Powertrain Blockset.
Updated description.

MATLAB Release Compatibility
Created with R2018a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor