Version 3.2
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.
Additionally, this project 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.
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 Simulation App to select model and run simulation for the Motor Drive Unit.
Improved Reducer component resources
- Updated the test inputs for the harness model to use Referenced Subsystems.
Improved testing
- More unit tests and the
buildfile.m
files for the Build Tool are added. In particular, tests for Button blocks' callbacks are added to check that the callbacks work as expected.
Improved code quality
- Custom rules for MATLAB code are added for MATLAB Code Analyzer.
The rules are to remind developers to follow best practices and coding standards.
See the
codeAnalyzerConfiguration.json
file in the Project root > resources folder. Custom rules are also used by the Editor and by the build tool's CodeIssues task.
Improved signal design for lookup table blocks
- Smooth signals (a.k.a. Akima spline) and piece-wise linear signals for lookup table blocks are now designed with the Signal Tool, which is stored in the Project root > Utility > SignalTool.
- The Signal Tool provides MATLAB functions and Apps for designing signal traces. The tool works with Simscape PS Lookup Table (1D) blocks and Simulink 1-D Lookup Table blocks.
- The Signal Tool has replaced the Signal Designer. The Signal Designer provided Simulink custom block library for designing and using smooth or linear signals. With the Signal Tool, signal design process is isolated from signal usage process. Models containing lookup tables do not depend on the Signal Tool.
- Timed Trace Builder App is added to the project.
The app is a uifigure-based app built with the Signal Tool.
The app is used to design timed signal traces with high-level properties.
Generated data are used in some lookup tables as simulation inputs.
Streamlined model set up
- Selecting a referenced subsystem is done by clicking a button placed right next to the Subsystem Reference block.
- Custom functions to change a referenced subsystem have been removed.
- The Inputs blocks in harness models are now Referenced Subsystems. Some smooth signal traces in the Inputs are now designed by the Signal Tool.
Improved isolation of simulation case scripts
- Simulation case scripts directly use the product API as much as possible. The simulation case scripts for the same model do very similar operations that were used to be managed by custom functions to avoid writing similar code in multiple places. However, the use of custom functions was making the comprehension and modifications of the scripts hard. The scripts are now more isolated from each other and easier to figure out how to modify individually.
Improved discoverability and organization of test files
- Test files are stored in the same folder with their targets.
- Test files are named as
unittest_*
,uitest_*
,uptodatetest_*
, oruiuptodatetest_*
so that the purpose of each test file is clear from its file name. - Separating test files by their purpose makes it easy to run related tests only.
Better organization of utility tools
- Utility tools are now organized into separate name spaces based on their functionality. See the folders in the Project root > Utility.
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.