Back to Blog
Blogs 10 min read

Three Phase Inverter Simulation in MATLAB: Step-by-Step Guide

This guide provides a practical, step-by-step engineering approach for building, setting up, and testing a two-level three phase inverter simulation in MATLAB using Simulink.

Himanshu Garg
Himanshu Garg November 25, 2026 0 views
three phase inverter simulation in matlab - Three Phase Inverter Simulation in MATLAB: Step-by-Step Guide

This guide provides a practical, step-by-step engineering approach for building, setting up, and testing a two-level three phase inverter simulation in MATLAB using Simulink.

Quick answer

To run a three phase inverter simulation in MATLAB, build the circuit with Simscape Electrical blocks. First add a DC source, then a six‑switch Universal Bridge (IGBT/Diode), and finally a three‑phase LC filter.

Control the bridge with the PWM Generator (2‑Level) block. Set it to either Sinusoidal PWM (SPWM) or Space Vector PWM (SVPWM).

Always insert a powergui block in the model. Set the solver to ode23tb and use a variable step size, or choose a discrete solver with a 1‑microsecond sample time.

Finally, run the FFT Analyzer to check that the output current Total Harmonic Distortion (THD) stays within the required limits.

Core Topology of a Two-Level Three-Phase Inverter

A two-level voltage source inverter (VSI) changes a steady DC input voltage into a three-phase AC output whose frequency and voltage can vary. The power stage has three half-bridge legs that share a common DC bus. Each leg has two self-commutated semiconductor switches, usually IGBTs or MOSFETs, and each switch is paired with an antiparallel free-wheeling diode. The diodes let the inductive load current keep flowing when the active switches turn off. To avoid a direct short across the DC bus (shoot-through), the upper and lower switches in the same leg must never be on at the same time.

Therefore, the control signals for the complementary switches include a short dead-time delay. In a typical 180-degree conduction mode, each switch is on for half of the electrical cycle, so the line-to-line voltage steps through positive, negative, and zero DC levels. Sinusoidal Pulse Width Modulation (SPWM) is the usual way to drive these steps and produce clean AC waveforms.

For a closely related example, see Power loss model and efficiency analysis of grid-connected seven-switch boost-type photovoltaic current source inverter using two power switches configurations.

Signal and Power Flow in MATLAB Inverter Simulation

This flow diagram illustrates how control signals and electrical power interact across the different blocks in a standard Simulink model.

  1. 1DC Power Source
    Provides the input DC link voltage (Vdc) to the inverter bridge.

    Modeled using the DC Voltage Source block.

  2. 2Reference & PWM Controller
    Generates three-phase sine waves and compares them with a high-frequency triangular carrier.

    Outputs 6 gate signals (g1 to g6) with dead-time.

  3. 3Three-Phase Inverter Bridge
    Switches the DC input using IGBT/Diode pairs to produce a pulsed AC voltage.

    Universal Bridge block configured with 3 arms.

  4. 4LC Low-Pass Filter
    Filters out high-frequency switching harmonics near the carrier frequency.

    L and C values designed based on switching frequency.

  5. 5Three-Phase Load
    Receives the clean sinusoidal AC voltage and current.

    Monitored via the V-I Measurement block.

Setting Up the Simscape Electrical Workspace

To build a three phase inverter simulation in MATLAB, open Simulink and start a new blank model. The simulation uses parts from the Simscape Electrical library (which used to be called SimPowerSystems). Do not mix legacy Specialized Power Systems blocks with newer Simscape foundation blocks in the same signal path unless you use the proper interface converters. First, add a DC Voltage Source block to stand for the input DC link. Then insert a Universal Bridge block. Open its mask and set the number of bridge arms to 3. Choose IGBT/Diodes as the switching devices. This one block contains all six required switching elements.

For the output, place a Three-Phase Series RLC Branch block and set it up as a resistive-inductive (RL) load. Connect the three AC terminals of the Universal Bridge (labeled A, B, and C) to the input terminals of your load or any intermediate filter stage. Finally, drag a powergui block into the model workspace. This block is required; it starts the state-space equations, controls the solver settings, and lets you run advanced tools such as fast Fourier transform (FFT) calculations.

For a closely related example, see How to Simulate Buck Converter in MATLAB: Simscape and State-Space Guides.

Implementing SPWM and SVPWM Control Logic

Switching signals are created by comparing a low‑frequency reference wave with a high‑frequency triangular carrier wave. For a basic sinusoidal PWM (SPWM), set up three sine‑wave generators that are shifted by 120 degrees (0, -2*pi/3, and 2*pi/3 radians). The frequency of these reference waves determines the inverter’s fundamental output frequency, usually 50 Hz or 60 Hz. The modulation index (ma) is the ratio of the peak reference voltage to the peak carrier voltage. To stay in the linear region, keep ma between 0 and 1.

Compare the reference waves with a triangular carrier that runs at the switching frequency, which is typically between 2 kHz and 20 kHz depending on heat and efficiency considerations. Simulink’s built‑in PWM Generator (2‑Level) block can do this comparison automatically and give you the six gate signals you need. If you want higher DC bus utilization, use Space Vector PWM (SVPWM) implemented with a MATLAB Function block to compute sector dwell times. This method raises the maximum linear modulation index by about 15.5 percent.

For a closely related example, see Sliding mode approach for control and observation of a three phase AC-DC pulse-width modulation rectifier.

Modulation Strategy Comparison in Simulink

Choosing the right modulation strategy affects DC bus utilization, harmonic performance, and computational overhead in MATLAB.

Factor Engineering view Why it matters
Modulation Method Sinusoidal PWM (SPWM) Space Vector PWM (SVPWM)
DC Bus Utilization Up to 78.5% of Vdc (linear range) Up to 90.7% of Vdc (15.5% increase)
Harmonic Performance Higher low-order harmonics Lower overall THD; optimized switching
Simulink Implementation Simple; uses standard PWM Generator block Moderate; requires sector calculation logic
Computational Load Very low; direct carrier comparison Higher; requires coordinate transformations

Designing the LC Output Filter

The raw output voltage of the inverter bridge is a series of high-frequency pulses rather than a smooth sinusoid. To suppress these high-frequency switching harmonics before they reach the load or grid, you must design a passive low-pass LC filter. The filter's cutoff frequency (fc) must be positioned to attenuate the switching frequency (fsw) while passing the fundamental grid frequency (fg) without significant phase shift. A practical rule of thumb is to set the cutoff frequency such that 10 * fg < fc < fsw / 10. The cutoff frequency is calculated using the equation fc = 1 / (2 * pi * sqrt(L * C)), where L is the filter inductance and C is the filter capacitance.

Select inductor values that limit the peak-to-peak ripple current to between 10 percent and 20 percent of the rated load current. The capacitor value should be chosen to supply the necessary reactive power at the fundamental frequency without causing excessive leading power factor conditions under light load.

Configuring Solvers for Switching Power Electronics

Power electronics simulations are mathematically stiff because the switching changes happen very fast and abruptly. If you pick the wrong solver, the simulation can take a long time, give algebraic loop errors, or even crash. Open the Model Configuration Parameters in Simulink to change these settings. For continuous-time simulations, set the solver to ode23tb (trapezoidal rule with backward differentiation formula) or ode15s. These variable-step solvers work well with stiff systems and automatically shrink the time step during switching events. Set the relative tolerance to 1e-4 and choose a maximum step size that is less than one-tenth of the switching period.

For real-time hardware-in-the-loop (HIL) testing or for generating microcontroller code, run the model in discrete mode. Change the powergui block to Discrete and give a fixed sample time (Ts) between 1 microsecond and 5 microseconds. This lets the simulation capture the fast switching edges correctly without missing any events.

Solver Selection Matrix for Power Electronics

Select the correct solver configuration in MATLAB based on your simulation objectives and model complexity.

Factor Engineering view Why it matters
Simulation Goal Detailed transient analysis of switching behavior Use variable-step solver 'ode23tb' with strict tolerances.
Simulation Goal Real-time Hardware-in-the-Loop (HIL) testing Use discrete solver with fixed step size Ts = 1e-6 seconds.
Simulation Goal Long-term thermal or efficiency studies Use average-value inverter models to bypass high-frequency switching.
Simulation Goal Highly inductive systems with snubbers Use 'ode15s' solver to handle highly stiff state equations.

Troubleshooting Convergence and Algebraic Loops

A common problem in power electronics simulation is an algebraic loop. This happens when a block’s input depends directly on its own output within the same time step. In an inverter, you’ll see it when voltage sensors are placed straight across inductive paths or when current sensors sit across capacitive paths. To break the loop, add a First-Order Filter block or a Transport Delay block with a very small time constant in the feedback path. If the simulation runs very slowly or stops, look at the snubber circuit settings. The Universal Bridge block automatically adds parallel RC snubber circuits across each switch.

When the snubber resistance is too high or the capacitance is too low, the solver has trouble with sharp voltage spikes. Change the snubber values to match the real device, or set the resistance to infinity and the capacitance to zero if you are using ideal switches. Also, make sure the DC link capacitor is big enough so the inverter doesn’t suffer a deep voltage drop when it draws pulsing currents.

Validating Waveforms and Analyzing THD

Once the simulation runs successfully, add a Three-Phase V-I Measurement block between the LC filter and the load. Connect a Scope block to monitor the line-to-line voltages and phase currents. The raw line-to-line voltage before the filter should show a clear three-level PWM pattern, while the voltage after the filter should appear as a smooth three-phase sinusoid. To perform quantitative validation, configure your Scope block to log data to the MATLAB workspace as a structure with time. Open the powergui block and select the FFT Analysis tool. Load your logged signal, select the signal channel representing the load current, and set the fundamental frequency to match your reference wave.

Run the analysis up to the Nyquist frequency to calculate the Total Harmonic Distortion (THD). For a grid-connected inverter, verify that the current THD is below 5 percent to comply with international standards such as IEEE 519.

Key takeaways

  • Always include the powergui block in your Simulink model to initialize state-space solvers for power electronics.
  • Select the ode23tb variable-step solver for continuous simulations to handle fast switching transitions without stalling.
  • Ensure complementary gate signals include dead-time to prevent short-circuits across the simulated DC bus.
  • Design the LC filter cutoff frequency to sit comfortably between 10 times the fundamental frequency and one-tenth of the switching frequency.
  • Use the FFT Analyzer in powergui to verify that the output current THD complies with IEEE 519 standards.

Questions engineers often ask

Why does my inverter simulation run so slowly in MATLAB?

Slow simulation speed is usually caused by using a general-purpose solver like ode45 on a stiff system, or setting the minimum step size too small. Switch to ode23tb or ode15s, which are designed for stiff systems, and ensure your snubber circuit values are realistic rather than near-zero, as extremely small snubber parameters force the solver to take tiny time steps.

What is the difference between continuous and discrete simulation modes?

Continuous mode uses variable-step solvers to find exact switching times, providing high accuracy for transient analysis. Discrete mode solves the system equations at fixed intervals (e.g., every 1 microsecond). Discrete mode is essential for code generation, processor-in-the-loop (PIL) testing, and reducing simulation times for complex systems.

How do I eliminate algebraic loop errors in my inverter model?

Algebraic loops occur when feedback paths contain no state-dependent delays. You can resolve this by adding a first-order filter block, a memory block, or a small transport delay in the measurement feedback loop. This breaks the direct algebraic link between the output and input calculations within the same time step.

How do I choose the DC link capacitor value for the inverter?

The DC link capacitor must be large enough to absorb the high-frequency ripple currents from switching and maintain a stable DC voltage. Calculate the minimum capacitance based on the allowable DC voltage ripple (typically 1% to 2% of nominal Vdc) and the peak output current, ensuring the capacitor can support the transient energy demands of the load.

Continue learning: three phase inverter simulation in matlab

Explore more practical power electronics guides and simulation tutorials on Fried Engineers.

Chat with Fried Engineers