How do I get the average of a signal over every certain time duration (simulink)?
66 views (last 30 days)
What I want do is I want to find the average over every 0.1 seconds of this signal, and output it as another signal within simulink. I've only been able to compute the overall average of this signal, not for every certain time duration.
To give some background, this is an amplitude key shifted bitstream. The duration a bit lasts is 0.1 seconds. If the bit is 1 it is represented by a sinusoid with a maximum of ~1 and a minimum of 0 (as can be seen in from 0 to 0.1 seconds of the signal). If the bit is 0, the signal is simply 0 for 0.1 seconds.
Therefore, once I average every bit duration (0.1s) the 1's will be represented as a value of ~0.5 as that is the average value of the sinusoid which represents a 1. Also, every 0 will be represented by a 0, because every 0 bit is represented by a value 0 lasting for 0.1 seconds.
If anyone could point me in the right direction, that would be greatly appreciated.
Jon on 8 Nov 2021
Edited: Jon on 8 Nov 2021
So I'm assuming you are looking for an output signal that has a sampling period of 0.1 seconds, which gives the average value of the last 0.1 seconds of data. I think you could do this with the combination of an integrator and a zero order hold. The idea would be to integrate the signal for 0.1 seconds, then divide by 0.1 seconds (giving the average value) then reset the integrator to zero. You would then pass that signal throuh a zero order hold block (in discrete blocks) using a sample time of 0.1 seconds to get just the average values.
Note you would have to set the external reset parameter of the integrator block to provide an external reset port, for example with a rising signal. Then drive this with the output of a pulse generator source block set with a 0.1 second period.
You may have to put in a little phase delay on the pulse so the signal doesn't get reset before the zero order hold samples it.