![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1601156/image.png)
Cycle by Cycle Average of switching signal in SIMULINK
4 views (last 30 days)
Show older comments
Hi MATLAB Community,
I have been trying to find cycle by cycle average of a switching signal in MATLAB. For example, these three switching signals when passed through a moving average block with average time of 1/switching frequency give their perfect average in other softwares as shown below. I want to do the same thing in SIMULINK.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1598731/image.png)
I deally, I would want the average of yellow switching signal (SCOPE1 in the ATTACHED FILE). The moving average block in SIMULINK does not give the desired results. Thanks
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1598736/image.png)
0 Comments
Accepted Answer
Mathieu NOE
on 26 Jan 2024
hello
I would suggest that any well designed low pass filter after the PWM signal should give you the original waveform
here my little demo attached (i could not really use your file) , generated with (R2020b) Simulink Version 10.2
here you can see the LP filtered PWM signal correctly follows the analog input signal that enters the comparator
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1601156/image.png)
before starting the slx file , you need to run this (for configuration) :
Fs = 1e5;
dt = 1/Fs;
sig_freq = 2; % Hz
% PWM low pass filter
fc = 25;
[B,A]=butter(3,2*fc/Fs);
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!