A PWM modulator demo written in MATLAB uses the figure to demonstrate the PWM (Class D) modulation process of a sine wave.
I uploaded the MATLAB script file (.m) as well as the MATLAB live script file (.mlx), which you can open by clicking the button below:
In the program, there are five plots, namely:
Figure of sine wave input
Figure of sawtooth wave reference
Figure that contains the input signal, reference sawtooth waveform and output PWM that shows the modulation process
Figure of the output filter process
Figure that compares the difference between the input signal and the filtered output signal
Ver. 1.2 Update: I redesign that program in live editor, it looks like this:
Now the following parameters can be changed by tweaking sliders:
Have fun playing around!