Thilina's Blog

I might be wrong, but…

Switch Mode Power Supplies MATLAB simulation 1.0

When dealing with switch mode power supply design, we faced a problem in simulating SMPS circuits since most of simulation software is not flexible with simulating circuits which has tapped transformers. We face this problem specially on simulating isolated switch mode converters such as fly-back converter.

MATLAB simulink SimPowerSystems block set gives a best solution in simulating switch mode power supplies. From this article I’ll work on design a buck converter works on continuous mode and another in discontinuous mode with calculations and to implement both on MATLAB simulink.

Design Problem


Design switch mode power supply (a buck converter) for Input voltage 30V, output voltage 20V and with 100µH of storage element for,

1. 100W resistive load,

2. 20W resistive load

Find pulse width D for 20 KHz of pulse frequency.



Continuous mode – Equations

Discontinuous mode – Equations







Case 1: 100W Resistive Load






Case 2: 100W Resistive Load



MATLAB simulation


For the simulations, in MATLAB simulink open the SimPowerSystems Block set. First you need to place powergui block on top of your simulation file which found in SimPowerSystems block set. You can select the DC source in Electrical Sources category of the block set and a MOSFET for switching in Power Electronics Category.

For the Components Inductor, Capacitor, Resistive load you need to place parallel RLC branch from elements category and you can select the appropriate component from its property window (parameter type drop down menu). Again for the power diode you have to use Power Electronic category.

For the electrical measurements you can use Measurements category in the SimPowerSystems block set and its output can be displayed by using the scope available in Simulink Sinks.

For the clock pulse for the MOSFET we can use the pulse generator available in Simulink sources. You can set pulse frequency by changing its period parameter and pulse width by its pulse width parameter.

Please note that the current measuring blocks must be set in series to the measurand and voltage measurement must take in parallel to them. I used matrix concatenate block to set all measurements as one output so that I can view them in single scope. Designed MATLAB model is as below.



Continuous Mode Results



Discontinuous Mode Results



2011 January 16 - Posted by | Electronics, MATLAB, Technology


  1. It is great work bro, i was wondering if you know simulation of Push Pull dc dc converter, the input v is 12 to 24 v and output 360v dc. i tired many times to simulate but i did not get any result till now , i am doing project so can you help please?

    Comment by AQ | 2011 July 4 | Reply

    • Hi..,
      I’ll try to simulate a basic push and pull dc dc converter and let you know 🙂 🙂

      Comment by Thilina S. | 2011 July 10 | Reply

  2. Great job thilina malli… i suggest you to use PSIM or PSPICE when designing SMPS ccts..coz thy are totally dedicated for Power Electronics simulations…

    Gayan Abeynayake

    Comment by Gayan | 2011 November 8 | Reply

    • Thanks a lot ayya.., never thought you are going to read this…,
      but the problem I was having is that OrCAD 9.2 (which I used to use) does not support to simulate systems such as fly-back converters, which has Transformers. But seems MATLAB supports those simulations as well.

      Comment by Thilina S. | 2011 November 8 | Reply

  3. Great job Thilina, I did not know that Matlab offers such type of functions as well, I am facing a problem in simulating a flyback converter which can convert 12 V dc to -200V dc, I have not a strong background in power electronics side could you help me with that if I give you more details and if possible can you simulate such a flyback converter for me

    Comment by naveed | 2011 December 17 | Reply

    • Hello Naveed,

      I would suggest that you use LTSPICE from linear technologies (it’s free). It is specifically designed for Power Supply design and analysis and if you look on-line they have a nice help section on yahoo groups which possesses a moderator (Helmut) who is a genius when it comes to simulating just about anything.



      Comment by Robert Thurman | 2012 January 2 | Reply

  4. Great Work…on this simulation. Any ideas on a H-Bridge Design using Matlab

    Comment by Joseph | 2012 March 9 | Reply

  5. hey nice work man but when i am trying the in matlab i am getting the following errors.

    Warning: You have required continuous-time simulation of a system containing switches or nonlinear elements.
    The ode23tb variable-step stiff solver with relative tolerance set to 1e-4 is recommended in order to get best accuracy and simulation performance.
    For some highly nonlinear models it may be necessary to set the “Solver reset method” parameter to “Robust”.
    See “Improving Simulation Performance” chapter in SimPowerSystems documentation for additional information on how to select an appropriate integration method.

    Invalid port dimension 1 has been specified for input port 7 of ‘simulink1/Matrix Concatenate’. In multidimensional array mode, the sizes of dimensions other than the concatenate dimension must match for all input and output ports. This requirement is violated along dimension 1 of this input port because the specified size 1 is not the same as the size 2 specified by some other port.

    Comment by dhananjay | 2012 September 24 | Reply

  6. sir if u got this please send me the circuit for the simulation model in matlab for flyback converter,,,,plz m working on a project need help,n plz gv reply

    Comment by ritu singh | 2012 September 25 | Reply

  7. how to simulate isolated topologies like flyback or forward converters in matlab .

    Comment by anirudh | 2013 September 16 | Reply

  8. Hello
    Do you have any Matlab files available for this simulation?
    Thank you!

    Comment by Nathan | 2015 November 10 | Reply

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: