How to calculate the duty cycle of a time signal in a for loop?
5 views (last 30 days)
Show older comments
Susan on 14 Mar 2023
Commented: Susan on 16 Mar 2023
I have multiple time signals and like to compute their duty cycles automatically within a "for loop". For example the duty cycle of the following signal is 74.29%. The signal is attached and the sample rate is 15360000.
Assume I have a bunch of these signals. How can I calculate the ratio of the pulse width (duration of the on state) to the pulse period (the total duration of an on-and-off state) for each signal in a for loop?
Thanks in advance!
Walter Roberson on 14 Mar 2023
wr = real(waveform);
wi = imag(waveform);
subplot(2,1,1); plot(wr); ylabel('real');
subplot(2,1,2); plot(wi); ylabel('imag');
mr = movmedian(wr, 5);
mi = movmedian(wi, 5);
mean(abs(mr)<0.01) * 100
mean(abs(mi)<0.01) * 100
More Answers (0)
Find more on Matched Filter and Ambiguity Function in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!