Here we will find out the charge and current inside a given circuit by solving a Differential equation using Simulink.
Simulink finds one of its greatest use in the analysis of an Analog Circuit. Where one can use it to analyze the Voltage Currents Characteristics of electronic circuits.
Here we will find out the charge and current inside a given circuit by solving a Differential equation using Simulink.
According to Kirchoff’s Law, We have
The above equation can be solved and the equation of charge can be obtained as a function of time, but here in simulink we simulate the above equation by modifying the given sine wave input signal by using required blocks and measure the output at some point of the flow using a scope.
the Equation can be written as:
now Let L=1, C=1/3 and R=4, then
A Simple Beginning
Once you open MatLab you can open Simulink by typing ‘Simulink’ in the command line. Once you open Simulink library browser you can create a fresh Simulink project and start adding blocks from the library.
Here the input signal is a sine function of time with a gain of 5, so we select a sine input signal from the Simulink toolbox, then we connect a gain with value 5 to this.
Plot of Sine wave
Now we place an adder block (with three input terminals) in the Simulink workspace and connect the the input sine signal along with the gain to one input terminal of the adder.
Note: You can edit the properties of any block by right-clicking the block and selecting properties.
The output of the adder is connected to the scope. When analyzed the output of the scope is a sine wave with amplitude equal to that of the gain (i.e 5) .
Note:Here the adder block provides no functionality it is just used to avoid confusion to the readers at a later stage, the output remains the same even if the adder block is removed.
The output can be viewed by running the simulation (ctrl+T) and then double clicking on the scope icon.
The equation of what we have done is as follows:
The Integrator Block
Now we will start simulating the differential
equation by using the integrator blocks. Here we need 2 integrator blocks, as the highest order derivative in this equation is 2.
The output from the adder block is removed from the scope and is connected to the input of the integrator block and the output of the

Resultant Plot
integrator block is connected to the input of another integrator block. The output of this integrator block is connected to the scope.
This way we can integrate the output of the adder block twice before viewing it in the scope.
Now we can set the initial conditions for the integration by each block. Right click the integrator blocks and select properties set the initial value parameter as 0 for the first integrator block and 0.5 for second integrator block.
The equation of what we have done is as follows:
, with y=0 and y’=0.5 initally.
On solving we get,
, which is the same curve plotted on the right side.
The Complete Circuit
Now we need to get the other two terms (i.e 1st and 2nd order terms of q). For that we add another root to the output of the first integrator block that gives (that gives the dq/dt term) and connect it to one terminal of the adder block then we add a gain block in between to represent the multiplier.
We do the same thing for obtaining the q term, we connect the output of the second integrator block before the scope to the third input of the adder through a gain block (with gain 3).
The Output
Now the resultant equation is obtained by solving the given differential equation:

Plot of Current Vs Time

Plot of Charge Vs Time
Thats it!!
Thank you for following this tutorial, I hope you have followed all the parts of this tutorial. If you did’nt you can feel free to post your doubts in the comments section. You can also download the source files and run the simulation in Simulink, then you can experiment with the different blocks until you get a hold of it. All the Best!
Download the Source code
Similar topics you might like…
Make a Light Sensor using an LDR
Interfacing a CD-Rom stepper motor
DTMF Decoder
Serial Communcation between microcontroller and PC
Great information! I’ve been looking for something like this for a while now. Thanks!
Thinking comes more easily if you have something to say.
Sent from my Android phone
it was very interesting to read http://www.ingeniumblog.net
I want to quote your post in my blog. It can?
And you et an account on Twitter?
Your articles are for when it abosultely, positively, needs to be understood overnight.
hi………i like 2 call u adi……..k………
ok.adi u r gorgeous in ur photo.u hav got a cute look,handsome laugh
Thank you.I hope I can improve through learning this respect. But overall, it’s very nice. Thank you for your share!
Knowledge wants to be free, just like these atrciles!
Hello. remarkable job. I did not imagine this. This is a excellent story. Thanks!
Wow, incredible blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your website is magnificent, let alone the content!
My brother recommended I might like this web site. He was entirely right. This post actually made my day. You can not imagine just how much time I had spent for this info! Thanks!
I’m not easily imeprssed. . . but that’s impressing me!
Nice website ! I’ve just bookmarked it.
Thanks for your article! I really liked it.
Bookmarked! Thanks for an amazing post, will read your others posts.
That’s what we’ve all been waiting for! Great potisng!
I simply want to mention I am beginner to blogs and honestly savored this blog. Very likely I’m want to bookmark your site . You definitely have impressive posts. Cheers for sharing with us your website.
Heya ours english like Analog Circuit Analysis with Simulink
Hiya. I truly desired to place a good short note and let you grasp that in fact I’ve been following your personal page for quite some time. Keep up the super task and I am going to be checking back again relatively quickly.
Hi there admin, I truly wished to place a swift statement to admit that in fact I loved your specific post. Thanks!