|
You need to spend some time look at the Simulink doc to understand some fundamentals of how it works, and pressing the help button on each block to see how it specifically works.
Create a new model, and have
Sine Wave -> buffer -> mean -> unbuffer -> scope
Make only one change from the default values:
change the "Sample Time" parameter of the Sine block to be 2*pi/64.
When you run the model the scope should show zero, but why?
The sample time of the Sine has been set so that it has 64 samples per cycle of the sine wave.
The buffer block has a default length of 64 samples with no overlap, so it fits one complete sine wave in it.
The mean block takes each buffer (i.e. all 64 elements) and takes its mean, which will be zero for a complete cycle of a sine wave.
That gets unbuffered and displayed on the scope.
Now change the Sine's sample time to be 2*pi/128.
The buffer block still holds 64 samples at a time, but now 64 samples only represents half of a sine wave.
The mean block takes the mean, which gets unbuffered and displayed.
Nothing happens on the scope for the first 64 samples because that's the buffer first filling up, at which point the output jumps the the mean of the positive half of a sine wave which is a little over +0.5.
Then after another 64 samples the buffer contains the -ve part of the sine wave, which has it's mean taken and displayed, just less than -0.5.
The result will be a square wave.
Now play around with different sample times and with overlapping the buffer.
Depending on what you ask the blocks to do it is very possible to have a sine wave as the output of the mean of a series of samples from a sine wave.
Infact that's the basis of averaging filters.
Phil.
|