File Exchange

image thumbnail

Selective Harmonic Elimination PWM (SHEPWM) of two level, three phase inverter

version (98.9 KB) by Rohit Baranwal
SHEPWM of 3 phase, 2 level inverter with 3, 5 and 7 switching angles per quarter cycle.


Updated 07 Jul 2016

View License

This set of models and scripts demonstrate how SHEPWM works. The Simulink models generate pulses for two level inverter based on precomputed SHEPWM angles and modulation index. Three models are provided, with 3, 5 and 7 switching angles per quarter cycle of the output fundamental frequency. The models have preload functions, that compute the angles whenever the models are started. The models also have sine triangle PWM with comparable frequency carrier to show how SHEPWM excels at low switching frequencies, relative to output fundamental frequency. For 5 and 7 angles per quarter cycle, there are four solutions of angles and some are better than others. In the given scripts, 2 sets have been provided for each case (3,5 and 7 pulse).
The preload functions have also been provided separately as .m files, with comments about the initial values given for Newton Raphson method for each iteration. The expressions used in the equations for SHEPWM are taken from the following reference.
V. G. Agelidis, A. Balouktsis, I. Balouktsis and C. Cossar, "Multiple sets of solutions for harmonic elimination PWM bipolar waveforms: analysis and experimental verification," in IEEE Transactions on Power Electronics, vol. 21, no. 2, pp. 415-421, March 2006.
doi: 10.1109/TPEL.2005.869752

Cite As

Rohit Baranwal (2020). Selective Harmonic Elimination PWM (SHEPWM) of two level, three phase inverter (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (12)

Yinglun Mai

Finally, if you do not mind, could you please contact me through e-mail? My e-mail is, and I am really grateful for the help your model brings to me and I can express my problem via picture or txt.
Thank you and wish for further contact.

Additionally, the switching angles you provided are really close (40.06, 40.2). Are you certain that these are the right angles?

Yinglun Mai

This Model helps a lot, but when I just use three switching angles to replace this modulation index, I find it that when N =3 and I choose angels like 7.377 40.0688 40.2414, the output line-line voltage peak value is over my input voltage peak value.
So, is this model somewhere wrong?

@Pradeep. Are you saying that the DC bus voltage (input) is higher than the output voltage? Or are you saying that the modulation index is greater than 1.15, implying that the line-line voltage is higher than the DC bus?

My input voltage is always higher than the output voltages,how it is possible in inverters

payam lord

Velide, maybe you can try to run the .m scripts to see if they run? If they don't run then there could be a missing toolbox or something else improper with MATLAB installation. Please note that you need Simscape Power Systems to run the .mdl files, so make sure you have that.


when ever i am tring to run the .mdl file my matlab is terminated and stoping to work. i am using R2012a. May i know the reason

hello friend. I understand how set initial angles. I calculated few day ago 9 angles pwm. Also i calculated angles for Angles =2,3,4,5,7,9.
7,9 angles pwm has more 4 variants initial angles.
3,5 angles - 4 variant.
2,4 angles - more 2 variants.
Proposed in u files 2 variants initial angles for 5 angles mode not optimal, because harmonic number 17 biggest (19% & 17% from 1st). I redused it to 8.5%, but increase to 12% harmonic number 19 (Calculate the third set, phase current form has become much better).
I 100% know that can still greatly reduce this harmonic (Alstom use shepwm for N=5 and have another form phase voltage, and have less noise in form phase current). I think i will solve this problem on this week.
If u interesting we can discuss it. U know my email :-) & sorry for my bad english, write without translator

Hi. You can refer to these publications:

There are others as well, but these seem to be the easiest to follow. I was not able to find any publications that give the initial angles for 9 angle SHEPWM.

Hey friend. Can u help me with initial angle for 9 angle mode. I try set a lot of initial angle but matrix always singular. May be u have some idea how calculate correctly initial angles. My email:

Thank u for u job. U work great help me


Updated the description regarding THD. Out of multiple possible solutions for firing angles (for a given number of angles per quarter cycle), some lead to better THD than the others, as also given in the reference article (by Prof. Agelidis).

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: Selective Harmonic Elimination