| Author |
Message |
dav_mt
Joined: 12 Oct 2006 Posts: 11 Location: Malta
|
07 Nov 2006 19:58 sampling theorem matlab |
|
|
|
|
Hello ppl, i m questioning myself why is this happening.
ive implemented the following system using Simulink. basically i am feeding a 1kHz pure sinewave and multiplying it by a pulse having a period of 10 samples and pulse width is 1sample(10us). So effectively sine wave is being sampled at 10kHz.
When i set the simulation time to 10ms and obtain the frequency magnitude spectrum the amplitudes of my frequencies vary (number of samples here is 0 to 1000 therfore 1001)
When i set the simulation time to 9.99ms and obtain the frequency magnitude spectrum the amplitudes now remain constant ! ( 0 to 999 equals 1000 samples)
So why does varying the number of samples(through simulation time) has such a drastic effect? To transform into frequency domain, Matlab's fft function is used. Ive tried to check out doc fft to see wheter the number of samples have effect on the amplitude but I cant actually figure out whats happening.
this is the Matlab code being used,
stem(y,'b.-') <---- Time Plot OK
freq = fft(y) <---- changing signal to frequency domain
plot([0:length(y) - 1], abs(freq)) <----- Frequency Spectrum
note y is the number of samples
attached is a link to the simulink system
|
|
| Back to top |
|
 |
Hero
Joined: 06 Mar 2002 Posts: 145 Helped: 2
|
07 Nov 2006 22:12 sampling theorem in matlab |
|
|
|
|
Hi,
You need to study some basic DFT theory and realtions between time frequency domain. DFT supposes periodic signals with infinite duration. Also you need some informations about windowing functions and spectrum estimation.
|
|
| Back to top |
|
 |
Google AdSense

|
07 Nov 2006 22:12 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
dav_mt
Joined: 12 Oct 2006 Posts: 11 Location: Malta
|
07 Nov 2006 22:36 matlab program for sampling theorem |
|
|
|
|
| thanks for your quick reply, i will search something regarding discrete fourier transform even though i havent covered it yet in class. I assume its got to do with the way matlab carries out the dft.
|
|
| Back to top |
|
 |
echo47
Joined: 07 Apr 2002 Posts: 4206 Helped: 566
|
08 Nov 2006 0:46 matlab code for sampling theorem |
|
|
|
|
Hero is correct. It's not a MATLAB issue, it's a fundamental issue. If you compute the DFT of a periodic waveform, but you take a non-integer number of waveform cycles, you have a discontinuity, so you will see energy spread across the spectrum plot.
Consider what would happen if you repeatedly played that 9.99ms segment to your computer speakers. A small piece of the last waveform cycle is missing, so you will hear the sinewave plus a slight buzzing sound. That buzzing is the energy you see spread across the spectrum plot.
Remember this experience as you learn about weighting!
|
|
| Back to top |
|
 |
bcl
Joined: 24 Sep 2006 Posts: 41 Helped: 5
|
08 Nov 2006 5:49 sampling theorem dsp |
|
|
|
|
| Try sample the sinewave at 4KHz, 8KHz or 16KHz, i.e., keep fs=2^n*fc, n=1,2,3,4...
|
|
| Back to top |
|
 |