Version 3.0
This is a MATLAB® Project containing a Battery Electric Vehicle (BEV) model and its components such as motor, high voltage battery, and longitudinal vehicle. This project demonstrates Simscape's modular and multi-fidelity modeling technology.
The abstract BEV model is built in a simple and modular fashion, and it can run faster than real-time. It is suitable as a baseline model for drive cycle simulation to estimate vehicle's electrical efficiency and other vehicle-level information.
This project also contains the model of a detailed permanent magnet synchronous motor (PMSM) and controller. It captures the detailed behaviors of the AC motor drive unit and can estimate the electrical efficiency at the unit level.
A Live Script demonstrates how to obtain the electrical efficiency from the slow but detailed motor drive unit and use the result as the block parameter of the simple but fast motor drive block in the BEV model.
BEV system model:
FTP75 drive cycle simulation result:
Simple drive pattern simulation result:
Use BEV Project Navigator App to quickly access some key files and tools.
Use Vehicle1D Performance Design App to design the basic performance parameters of a road vehicle.
Use Motor Drive Unit Efficiency App for System Thermal Model to understand how the model parameters are affecting the motor efficiency.
Use Motor Drive Unit App to select model and run simulation for the Motor Drive Unit.
Past What's New contents have been moved to Change Log.
From R2025a, you can save Live Scripts as plain-text files.
- MATLAB: Live Code File Format (.m)
All Live Scripts in the project are now plain-text with .m
extensions.
The use of plain-text files improves the compatibility with source control systems.
Text-based search and replace work with not only conventional MATLAB code files but
also all Live Script files in the project.
A model for testing a component is now placed in the component top folder. This improves the discoverability of models for component testing.
Component models that are built as Referenced Subsystems such as Basic model or System model are stored in separate subfolders, such as Model-Basic or Model-System, respectively. Related resources for a referenced subsystem including simulation case scripts and test code files are saved in the same folder, improving the isolation of each component model.
For running unit tests,
the project now uses the Build Tool with buildfile.m
.
- MATLAB: Overview of MATLAB Build Tool
From R2025a, you can run Build Tool tasks using the Run Build button in the Toolstrips
in addition to using the buildtool
command on the Command Window.
- MATLAB: Run Build from Toolstrip
This project has several buildfile.m
files.
The Editor recognizes the buildfile.m
file as a Build Tool file
and shows the Run Build button in the Editor Toolstrip.
The project finds the buildfile.m
file in the project root folder
and shows the Run Build button in the Project Toolstrip.
Reducer component now has a test model and supporting files.
Also, the Reducer component uses Simscape selective data logging, which simplifies the way data in Simscape blocks is logged during simulation. Other components will use the same approach in the future.
- Simscape: Log Selected Block Variables
- Simscape: Log Selected Variables Programmatically
To edit physical input signals using PS Lookup Table (1D) blocks in the Reducer component, Signal Tool is used.
-
For graphically editing signals, you can use
SignalDesignApp
which is included in the project and you can find in Project root > Utility > SignalTool folder. -
For programmatically editing signals, you can use functions in the
SignalTool1
name space. See the Live Scripts in Project root > Components > Reducer > Model-Basic > SimulationCases folder for example usages.
Supported MATLAB Version: R2025a or newer releases
Required: MATLAB, Simulink®, Powertrain Blockset, Simscape, Simscape Driveline™, Simscape Electrical™
Optional: MATLAB Test, Parallel Computing Toolbox™
Open BatteryElectricVehicle.prj
in MATLAB, and
it will automatically open the project main page BEV_main_script.html
.
The script contains the description of the model and
hyperlinks to models and scripts.
You can try this in MATLAB Online. In MATLAB Online, from the HOME tab in the toolstrip, select Add-Ons > Get Add-Ons to open the Add-On Explorer. Then search for the submission name, navigate to the submission page, click Add button, and select Save to MATLAB Drive.
BEV system model and its components are tested using MATLAB Unit Testing framework.
-
Some tests are passing tests that check if code runs or not and do not use the
verify*
functions. They simply run scripts, functions, classes, or models, and check that they run without errors. Passing tests are designed to finish quickly so that they can be used in day-to-day development activities in a short iteration cycle. -
This project uses the buildtool with
buildfile.m
to check code, run tests, measure code coverage, and generate test reports and code coverage reports. Seebuildfile.m
in this project for how the buildtool is configured. Checking code with the buildtool is done by Code Analyzer.
The git repository of this project in github.com/mathworks is set up for
test automation using GitHub Actions and MATLAB Actions.
Unit tests in this project are run automatically
when changes are pushed to the repository in github.
See the .github/workflows
folder for configuration files.
Visit the File Exchange page of this project.
Hybrid Electric Vehicle Model in Simscape
- Provides an abstract power-split HEV model. The level of abstraction is similar to this project.
- https://www.mathworks.com/matlabcentral/fileexchange/92820
Electric Vehicle Design with Simscape
- Provides BEV design workflows using detailed models for detailed analysis.
- https://www.mathworks.com/matlabcentral/fileexchange/124795
See license.txt
.
Copyright 2020-2025 The MathWorks, Inc.