Unlock all 72 lessons of Simulation and Design of Power Converters for EV using MATLAB and SimulinkFull course ₹40,000 · paid
MATLAB and Simulink Basics Before the HEV Course
A free lesson from Skill-Lync's Simulation and Design of Power Converters for EV using MATLAB and Simulink course, on Grow by Skill-Lync · Last updated 16 Nov 2026 · Session: “Introduction to HEV using MATLAB and Simulink”
What will you learn in this free Simulation and Design of Power Converters for EV using MATLAB and Simulink lesson?
The instructor tours the MATLAB environment, uses the command window as a calculator, and writes scripts for quadratic roots and a sine and cosine plot. The lesson then builds Simulink models with constant, add and display blocks and opens a built-in example that takes the maximum of several sine waves.
- MATLAB windows, workspace and command line
- Writing and running .m script files
- Building a Simulink model from library blocks
- Viewing sine waves on a scope
What comes after lesson 1?
The next free lesson is lesson 2, “Where Switch Mode Power Converters Are Used” (7 min). Later in Skill-Lync's Simulation and Design of Power Converters for EV using MATLAB and Simulink course (paid): lesson 6, Introduction to Switched Mode Power Converters, Performance and Analysis of Buck DC/DC Converter Week 1 Session 5; lesson 7, Introduction to Switched Mode Power Converters, Performance and Analysis of Buck DC/DC Converter Week 1 Session 6; lesson 8, Introduction to Switched Mode Power Converters, Performance and Analysis of Buck DC/DC Converter Week 1 Live session. The full course has 72 lessons (22 h 12 min of video); see the course overview or its price and syllabus.
Lesson transcript
Machine transcript of the lesson audio (lightly cleaned). Technical terms may contain errors; the video is the reference.
Hello everyone, welcome to the course introduction to HEV using MATLAB and Simulink. Before getting started with HEV course, we will learn about MATLAB and Simulink. In this video, we will learn about MATLAB environment, we will learn how to use command lines, we will write a basic program in MATLAB, we will learn about Simulink environment and at last we will create a basic model using Simulink. To do HEV course, you need to install MATLAB in your PC or laptop with some required toolboxes like Simulink, Optimization Toolbox, Simscape, Simscape, DriverLine, Electrical, Fluid, Multibodies, Simulink, Design Optimization, Stateflow, Vehicle Dynamic Toolbox and Powertrain Blockset.
Now, we will see about MATLAB. So, when you open MATLAB, it will look like this. I have MATLAB 2019 version. You can get MATLAB latest version from MATWORKS. Inside MATLAB, you have different windows like current folder. It shows the directory path on which folder you are working on. You can also change the directory path from here according to your needs. Command window. It's a working platform where everything goes. Workspace, all the variables are defined and stored into the workspace area. You can also write codes in MATLAB using script files.
You can open any script file or .m files inside MATLAB. You can import data. You can create a new variable. You have an option of Simulink which we will see later on. You have an option of add-ons. Suppose you want to add any features, features, features, functions or block sets to MATLAB. You can click on add-on. You can also take help from MATLAB documentation. Command window. Command window, we can use it as a calculator. For example, we will write a matrix and we will find the determinant and the rank of that matrix.
To write the matrix, we will start with A is equal to 1 to 2. This is how you write a matrix. I have written a 2 by 2 matrix. You can see it is stored into the workspace area. Now, for finding the determinant, we will write x is equal to 4. You can see in workspace area x is equal to 4 is stored and the determinant is 4. For writing the rank, we will write y is equal to rank of A. So rank is 2. Similarly, you can add 2 numbers. You can subtract 2 numbers. You can add 2 matrix. You can multiply 2 matrix. You can use command window as a calculator.
Now, we will write a code. Now, we will write a code and see how it works. For writing code, we will click on script files. You can see a blank page. Here, you will write code. For example, we will write the code for finding the quadratic roots of equation. So, to write that code, we will start with CLC. We write CLC because it will erase all the previous variables after running this program so that the variables can have new values. We will write CLC. We will write CLC. Then, after that, as we know, the standard equation for quadratic root is ax square plus bx plus c.
So, we will give the inputs of a, b and c. We will write a equal to input enter a and b. We will write enter b. We will enter c. Now, we will write d which is d is equal to b square minus 4ac. We will write 4ac. Now, we will write an if condition. If d is greater than 0, it will give real roots. So, d greater than 0, it will give imaginary roots. So, d greater than 0, greater than or equal to 0. It will give real roots. So, the real roots are x1 into minus b plus square root of d into a, b.
Now, we will print x1 into x2. Now, we will print x1 into x2. Now, we will print x1 into x2. So, for writing that f, we will write like f. Print f. First, we will print its real root. So, we will write like real root. Then, we will print g. With printing x1 and x2, we will write %g. Then, batch class n. Then, we will write x1, x2. Now, we will write an if condition. Sorry. Now, we will write an else condition. Stating that if d is less than 0. We will write like else. Now, we will d less than 0. It will print complex root. We will write f. Print f. Complex root.
Now, we will end the if statement. Now, we will end the if statement. Writing end. We will save this. We will save this code. I am saving it into my matlab folder. So, we will enter here. Here. Here. I will write a file name like quadratic. So, I will just write quad file save. You can see a green box over here. This means there is no warning found. And it is perfect to run. So, now, I will run this code. Now, they are asking me to enter the value for a. I will enter it as 1. I will enter b as 5. I will enter c as 4. I will run it. You can see it is printing real root.
Now, we will write a code. Now, we will write a code. Now, we will write a code to plot the graph for sine and cosine. For writing the code for that. Now, we will start. We will again start with clc. So, that it clears all the previous variables. Now, we will give a new variable like t. That is time. Which is from 0 to 5 with the interval of 0.01. So, it will go from 0 which has an interval of 0.01 till 5. Now, enter. We will write frequency for that.
We will write frequency as 0.5. And we will write amplitude which is equal to 5. Now, we will write the equation for sine. That is x is equal to amplitude into sine. 2 into pi into pi. we will write amplitude which is frequency into time. Now we will write for cos y is equal to cos into 5 into f into t. Now we will plot time by writing plot t comma x and we will plot for cos also by writing plot t comma x. Why? But to plot both the graphs into a single graph, we need to write line like hold on. It will hold the first plot for few seconds and then plot the second graph.
Now you can also give legend that is labeled the waves by giving legend. Now first plot will be sign. So I will just write sign and our second plot will be cos. So I will write like cos. As you can see here it's giving a warning. So we will see like we didn't give a semicolon in this. That's why it was giving a warning. After putting semicolon you can see there is no warning and it's ready to go. So we will again save it where I saved my old file. I will just save it there.
We will give a name just like plot sin cos. Now we will run it. As you can see the graph for sin and cos is here. And you can also see that there is a legend which is showing the blue one is the sign and the orange one is the cos with amplitude of 5 and frequency of 0.5. This is how you write code. This is how you write code and plot it in MATLAB. Now we will move on to Simlink. So when you click on Simlink. This is the start page of Simlink.
There are different kinds of model. According to your needs you can select the types of block set. But for now we will learn what is Simlink and we will create a basic modeling. So we will create a click on create model. So you can see there is a Simlink page. Here you can see you have if you want to create a new model. You can go on this. You can click here. If you want to open any Simlink model. You can click here. You can select the types of block set which is required for your model from library browser. Here. So when I open library browser. It works like this.
Here you can select different types of block sets. Here you can select different types of block sets according to your needs. So we will start. We will just familiarize ourselves. Some of the block sets which we know. Like derivative integrators. We know PID controllers. Then discontinue. We have rate limiters. Relay. You have like delay. Then first order hold. Then math operators. You have add. You have add. You have subtract. You have add. Subtract. Divide. Dot product. You have sign. Then you have sum. You have subtract. You have square root. This is an exponential block set. So there are different types of block sets according to your needs. In this.
So if you want to add. So if you want to add any block sets. Like this is here. You can display the values. Like answers. This is scope. It shows the input signals. So suppose. So suppose you want to. Use any block. In that single page. Either you can right click on it. And you can do. Add block to the model. Untitled. Or you can just drag. And drop it over there. Or you can. Double click on this page. And you can write whatever block set you need.
So for example. So for example. We will add two numbers. So for adding two numbers. We need a block. Which will hold. The values of. The two numbers. So for that. We will take a constant block. Like 12 is a constant. So we will take a constant block. So we will just write a constant over there. You can see. You can see. You can see. We got a constant. You can just click on the constant block. So this is a constant block. So you can just enlarge it. Like this. So when you click on this constant block.
It will give a constant block. It will give a constant block. It will give a constant block. It will give the definition over here. What is constant block is about. You can also change the value of constant. Here. Like suppose. I write it as 10. And then you can also give a range. The constant block. Like minimum output and maximum output. So for time being. We will just write 10. And we will do apply. Okay. So this is a constant block. So this is a constant block. We need another constant block. To add. So we will just write constant. Again. So we got a constant block again. This enlarge it. Good. Yeah. So now again. You can also double click on that. And you can change it over here. Or else. You can just. Do it from here. Just write 20.
20. So it got changed over here. See. 20. It's changed. Now you need an addition block. Which will add these two numbers. Right here. You will just write add. So this is an addition block. 20. To make the connection. You can either drag from here. And drop it here. Or you can just click here. And then click here. It will automatically show you a path. And you just click here. It will get connected. 20. The output. For the output. We need the answer to be displayed. So we need a display block. Or a block in which the answer gets stored.
20. So we will just. So we will just. Right here. And we will do display. So we got a display block. And just click on display. 20. So this is the display block. It's showing a connection in here. You just click here. And it's got connected. 20. So if you double click on and block. You can see. You can change the shape of the block. You have a. A. Brief intro about. What is. A. Brief intro about. What is. Sum block or add block. About. Now we will run this program. As it's a very small.
Function. So we will. Take two seconds. We will just. Run this. Now you can see here. It is compiling. It got compiled. And. Here. See. Now you can see the answer in the display block. Which is 30. That is 10 plus. 2 you can also change the values suppose I want I can change it to 100 now I will run it again see it is 110 so this is how you use in blocks to add to numbers we can also do the addition in the command window we can also write the program for addition or we can also do it using blocks you can also change the sign suppose I want to change it this to minus I will change it to minus you do apply you can see here the sign got changed now you run it again it's giving minus 90 that is 10 minus 100 is equal to minus 90 so this is how you create a symlink model in symlink you will see an inbuilt example in build example that is find the maximum value of the input I just click on this. So it's like I'm taking an help from MATLAB documentation. So this is, we can see this and we can open this into our Simulink. So I'll click here. As you can see, it is opened into the Simulink page.
Now, you can zoom this figure and make it large by clicking on zoom or you can do fit to the view. If you do fit to the view, it will automatically get fit in your screen or in the page. So you can, instead of constant block, in the previous case, in this case, they used a sine wave. So if you click on this sine wave, you can see that sine wave, the equation is amplitude into frequency, into sine, into frequency, into time, plus space. Then you can write amplitude over here. Then you can write amplitude over here. You can give frequency, you can give phase, phase, that's why they have given. So we'll take the same condition for sine waves too.
For sine waves too, you can see they gave the amplitude, the frequency and everything here. So you can take the same condition. This is the minimum and maximum block set. So you have a definition of minimum and maximum block set. Here you can change the number of inputs, like how many inputs you need. For this case, they have taken two inputs. So it's written two. You can also change what you want to find. Suppose you want to find maximum or minimum. So in this case, they are finding maximum. We'll do for maximum only.
So this is the score where you plot the graph and this is the display. It will give value. So what do you think this model will do? So this model will do the function like, it has two different amplitudes and in this block, it is given as maximum. So it will plot a graph, which shows the maximum value from both the graph, from both the sine waves. So I'll run this program. So if you do run, got compiled. This is the plot actually. So in this, the yellow line is the sine wave one and the blue line is the sine wave two and the orange line is the minimum and maximum.
So as we will not be able to understand this. So for the better understanding, we can separate all the graphs like from layout. And how many graphs are there? There are three graphs. So you can select how you want all the three graph like column wise or the row wise. So I'll just do it as column wise. So when I do it column, it will show me the column wise. So here you can see sine wave one with an amplitude of one and phase of pi.
Here this is sine wave two with a phase of zero. Now this is minimum and maximum. So the minimum and maximum are like, we have taken a condition of maximum over here. So we will get the graph according to that. You can see six is the maximum. Then it will go to minus one because minus six is lesser than minus one. So it will take maximum of both. So minus one. Then again, one minus one, one. Then again, it will go to six. This is how you do this. So now we'll try to add one more sine wave and see what is the condition.
So for that either you can write here sine wave or for to make it easy. You can just copy this and you can paste it here. You got a sine wave three over here. So now you'll double click on this. We'll change the amplitude. I'll write the amplitude as 10. Again. And we'll take the same condition. And we'll take the same condition. We'll do apply. And OK. So now we'll connect this to maximum block. For the connection, we'll just click here and we'll write it here as three.
Because we're taking three. Again we'll do OK. So here you've got input from here to here. Now you need to connect the sine wave to the scope. For that you just give a right click over here. OK. And here you can see block parameters. And here you can change the number of. Like here. Now we need four inputs. So give it as four. We'll do apply. OK. Now the input came here. Now you will connect this. To this. To this. Now we'll run the program. So this is the sine wave one. Sine wave two.
With six. And this is the. So we'll give again. Go and change the layout. Like now we need four layouts. So we'll just click here. We need four. So I'll take a. So now. So now. So now. It is showing me. Wave. It will give me the wave like. This is 10. With face of. Uh. Five. This is six. This is the. One. This is the. One. We'll run this. Ah. See. Here. We got a. Face. Like 10. With a face of. Zero. And here we got one. So. And here it is six.
So you can see the minimum maximum mass. It will go till 10. And then it will go to minus one. Then it will go to. One. Then minus one. And then again 10. You can also change. The. Frequency over here. Like. I have taken only one. So you can change it to two. Four. Or anything. According to your wish. So this is how you. Plot the graph. For sine and. Sine wave. In sim. Using sim link. Thank you.