Electric Vehicle Simulation in Simulink 

 December 31, 2020

By  Anish Yadav

Learn how to create an optimal Electric Vehicle model by using Simulink. Conventional vehicles utilize petroleum-derived fuels to provide good performance and long-range. But conventional vehicles having certain disadvantages such as low fuel economy and exhaust gas emission causing environmental pollution. So, to overcome these disadvantages, electric vehicle technology is useful. In this blog, the modeling of the electric vehicle has been discussed. Real key parameters have been considered to create an optimized model. By comparing the vehicle's actual speed and input drive speed, we examined the electric vehicle's optimal performance. The electric vehicle's energy consumption value is compared based on the battery's initial and final charging. The effect of different parameters on vehicle performance and energy consumption has been examined.


The electric vehicle's energy conversion efficiency is more than the energy conversion efficiency of a conventional vehicle. The battery is going to be an efficient source of power. The model simulation will provide batteries' behavior, and we can also observe how breaking will charge the battery.  Making a Simulink model has a lot of advantages. Before going for a real hardware model, we can observe and validate system key parameters inside a simulation to know how the system will function? Below simulation model will give you an idea about how electric vehicle components are arranged and how we can achieve optimal performance?

Block Diagram of the System

There are several components and a vast network of connecting wires in the electric vehicle. In the case of an electric vehicle, the conventional IC engine is replaced by the motor. The working fuel that is the battery pack is supplied to the motor. The below block diagram will show significant components of the Electric Vehicle system.

Block Diagram of Electric Vehicle

Block Diagram of the System

The key components of electric vehicles are the motor, vehicle body, controller, and battery pack. There are several types of motors used in Electric Vehicles. BLDC motors, Brushed DC motors, and AC Induction Motors are commonly used electric motors. The vehicle body includes a gearbox, differentials, and tires. Earlier, we used the battery just to start the engine. But now we are using the battery as a working power. Combinations of cells will create a module, and many modules will form a battery pack together. The motor needs a power supply from the battery to perform operations. Suppose we connect the battery pack directly to the motor. In that case, the motor will run at a rated speed, and speed control is not possible. We can control the speed of the motor with the aid of the controller. The controller will operate by taking input from the driver.

Simulink Model

I have divided the entire simulation system into four subsystems. The first subsystem contains the vehicle body. The second subsystem contains the motor and controller circuit. The third subsystem contains the driver input, and the fourth subsystem contains the battery pack.

Get Access to
Simulink Model!

Learn how to create an optimal Electric Vehicle model by using Simulink. Examine the vehicle's actual speed and input drive speed to analyze optimal performance and examine energy consumption value based on the battery's initial and final charging; Developed in MATLAB R2019a along with Simulink and Powertrain Blockset libraries

Vehicle Body Subsystem

First, I've developed a vehicle body subsystem. I have included tires, differential, gearbox, and vehicle body blocks from the Simscape library in the vehicle body subsystem. We can change the block parameters as per our requirements. Connect tires, differential, gearbox, and vehicle body blocks to each other to make the first subsystem.

Vehicle Body Subsystem

Vehicle Body Subsystem

Motor Circuit and Controller Subsystem

The motor will take controlled power from the battery and convert electrical energy to mechanical energy. The mechanical energy produced is supplied to the gearbox and mechanical rotational frame. To make the subsystem, I have added the motor circuit and controller block from the Simscape library. I have used a simple DC motor, and to control the DC motor, I have used an H-bridge controller. With the help of an H-bridge controller, I can apply acceleration, deceleration, and breaking. To control the PMW wave, I have added a controlled PWM voltage block. We can change the block parameters as per our requirements.

The below diagram will show connections between each block to make a subsystem.

Motor Circuit and Controller Subsystem

Motor Circuit and Controller Subsystem

Driver Input Subsystem

Longitudinal driver block from the powertrain block library produces normalized acceleration and braking commands based on reference and feedback speeds. Reference velocity will be given by the built-in drive cycle or we can generate our own signal by using the signal builder block. Feedback speed will be taken from actual vehicle speed. Based on the difference between the reference signal and the actual speed error will be generated. The error produced will result in acceleration or deceleration so that the vehicle's actual speed will try to match the reference speed.

I used the Longitudinal block and Signal Builder block to create the Drive Input Subsystem. The diagram below shows the connection between the blocks.

Driver Input Subsystem

Driver Input Subsystem

Battery Pack subsystem

The battery pack will provide power to the motor. Calculation of State of Charge (SOC) would give us information about how much we can drive before recharging and how much time we can use an existing battery. I have used a lithium-ion battery to check the SOC percentage directly. Battery charging and discharging we can examine with the help of SOC. The below diagram will show connections between each block to make a subsystem.

Battery Pack subsystem:

Battery Pack subsystem

Overall Model

Add powergui block to Simulation. Add scope and display block to examine outputs and behavior of the Electric Vehicle model. With the help of the signal builder block, I have created a reference signal. The reference signal and actual speed on the same graph will explain how the feedback loop is working. We can also calculate the average speed of the electric vehicle. With the SOC graph's help, we can analyze battery charging and discharge during deacceleration and acceleration command, respectively.

The below diagram will show the overall Electric Model that I have used to examine the vehicle's SOC percentage and average velocity.

Electric Vehicle -Overall Simulink Model

Overall Simulink Model


First, with the aid of the signal builder block, I have created reference speed. I have selected a top speed of 100 kilometers per hour. I've been simulating the model for 1,000 seconds. The speed increases for the first 400 seconds. The speed remains constant for the next 200 seconds, and the speed decreases for the remaining 400 seconds. The below Image will display the reference signal that I generated with the signal builder block's aid.

Generated Input Signal

Generated Input Signal

Suppose we look at the graph of the SOC percentage. In that case, the battery will be discharged non-linearly for the first 400 seconds, discharged linearly for the next 200 seconds. For the remaining 400 seconds, the battery will be charged and discharged according to feedback.

State of Charge

Graph of SOC %

The below graph will show how the vehicle's actual speed is following the reference speed of the input drive cycle.

Actual Speed and Reference Speed

Actual Speed and Reference Speed on the same Graph

Suppose we calculate the average speed for 1,000 seconds. In that case, it is approximately equal to the average speed that we got on the graph.


We have examined the SOC percentage and speed graph. The SOC percentage graph indicates that the battery is discharged when there is an acceleration command. The battery is charged when there is a deceleration command. The Speed graph shows that the actual speed tries to meet the reference speed by considering feedback. The model shows that the electric vehicle has traveled approximately 14 kilometers in 1,000 seconds. If we measure the average speed, the vehicle will travel approximately 50 kilometers per hour. This measured average speed is approximately equal to the average speed found on the graph. Here are some applications from this blog:

  • Conventional fuel has a high calorific value than batteries. Still, the battery conversion efficiency is more than conventional fuel. If we use hybrid technology, it would have a lot of potential and efficiency.
  • In the future, we can make electric vehicles powered by solar energy.
  • If we can replace current fuel-based transport with electrified transport, this would create an enormous advantage for the ecosystem.
  • Ultra-charging stations and the battery processing technology will have many advantages. It will have a significant effect also on the development of electric vehicles.

Get instant access to the code, model, or application of the video or article you found helpful! Simply purchase the specific title, if available, and receive the download link right away! #MATLABHelper #CodeMadeEasy

Ready to take your MATLAB skills to the next level? Look no further! At MATLAB Helper, we've got you covered. From free community support to expert help and training, we've got all the resources you need to become a pro in no time. If you have any questions or queries, don't hesitate to reach out to us. Simply post a comment below or send us an email at [email protected].

And don't forget to connect with us on LinkedIn, Facebook, and Subscribe to our YouTube Channel! We're always sharing helpful tips and updates, so you can stay up-to-date on everything related to MATLAB. Plus, if you spot any bugs or errors on our website, just let us know and we'll make sure to fix it ASAP.

Ready to get started? Book your expert help with Research Assistance plan today and get personalized assistance tailored to your needs. Or, if you're looking for more comprehensive training, join one of our training modules and get hands-on experience with the latest techniques and technologies. The choice is yours – start learning and growing with MATLAB Helper today!

Education is our future. MATLAB is our feature. Happy MATLABing!

About the author 

Anish Yadav

Greetings from Anish !!!. I graduated from Veermata Jijabai Technological Institute in 2019 with a Master's degree in Control System. I'm obsessed with all tech-related things, and I'd like to succeed in a stimulating and challenging environment that will provide me with opportunities for advancement.

  • Respected sir,

    I have watched “Electric vehicle simulation in simulink|MAtlab for beginners” from your youtube channel ” MATLAB Helper” and by connecting the same in my matlab, by giving all values as such , i am not getting the desired output. why is it so ….!
    [email protected]

    • Anish Yadav says:

      Please share your Simulink model via email with [email protected] and I will try to take a look on it.

  • Can you give me the simulation file?? I did exactly as shown in the clip but got an error

  • I have watched “Electric vehicle simulation in simulink|MAtlab for beginners” from your youtube channel ” MATLAB Helper” and by connecting the same in my matlab, in longitudinal driver where the info block is connected i didn’t understood

  • i have design the Electric vehicle model in Matlab as you are explained in the you tube. you are getting the current value is negative but i am getting positive value why it is so. could you please explain any one

  • Devansh Sachan says:

    I find the video quite interesting as it makes me understand minute things in a deeper way. since the animations were very appropriate, it made the entire thing very simple

  • Can you share me the Simscap libraries I have MATLAB 2021.
    I need for my Master Project….

  • Hi, I did this simulation. but it gives an error in the battery section and says: battery must be greater than exponential zone voltage. What should I do to fix this error?

    • Swapnil Sarwade says:

      I got same error . U solve this error .If yes can u suggest me for this.

  • Very informative, but I think 2 wheels are used which implies that this is either a bike/scooter. I would like to know how the graph and parameters change if 4 wheels are used.

  • Rithika Shenoy says:

    Respected Sir ,
    Thank you for providing knowledge on electric vehicle simulation

  • sanghieupk0 says:

    Can you replace Dc motor to BLDC motor huh?
    Make a video to guide me pls, tks !

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    MATLAB Helper ®

    Follow: YouTube Channel, LinkedIn Company, Facebook Page, Instagram Page

    Join Community of MATLAB Enthusiasts: Facebook Group, Telegram, LinkedIn Group

    Use Website Chat or WhatsApp at +91-8104622179