- A continuous signal can be generated in Simulink only by setting the sample time equal to 0.
- And the quantizer block performs discretization in amplitude and not on the time axis. Performing quantization prior to taking the FFT can also lead to information loss.
- To discretize a continous signal you may use the zero order hold block with the appropriate sample time.
- In order to discretize the sine wave you may right click on the block and set the sample time appropriately. In the above case it can be set to 1/5000.
Discretization and FFT in Simulink
5 views (last 30 days)
Show older comments
Hello,
I'm trying to do a discretization and FFT on a continous signal in Simulink. Result seems to be pretty good for a simple example (sinus) but I would like to hear the opinion of some experts if my way is right.
What I'm trying to do is the following:
I have a continious signal and want do discret it with a sample rate of 5kHz.
To make it easier for the example I will post here, I use a sinus with a frequency of 100 Hz and an amplitude of 5. I know that in this case the signal itself is discret. I entered as sample time of 10 kHZ to simulate a "continous" signal (see picture).
For the discretization I used:
Quantizer block (quantizer interval: 1/5000)
Zero Order Hold block (sample time 1/5000)
buffer (output buffer size per channel 5000
For the FFT I used:
Magnitude FFT Block (checked divide output by FFT lenght in the submodel)
two matlab functions (see pictures)
and an array plot.
All parameters are in the attachment.
Could someone check if the FFT and especially the discretization was done correctly?
Thanks in advance!
0 Comments
Answers (1)
Jyothis Gireesh
on 5 Aug 2019
Edited: Jyothis Gireesh
on 5 Aug 2019
Here are a few suggestions about discretizing a continuous signal and taking the FFT. The following pointers may be of help to you.
You may also improve the second matlab function matlabfunction2 using the following code snippet.
function y = fcn(u)
length = size(u,1);
p1 = 2*u(ceil(length/2):end,:);
p1(1,1) = p1(1,1)/2;
y = p1;
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!