Clear Filters
Clear Filters

Sampling of a Sine wave.

63 views (last 30 days)
Ketan Shende
Ketan Shende on 15 Mar 2021
Write a MATLAB script (m) file that builds an array e(k) which consists of the waveform sin(2π*10t) sampled over a 1 second time interval at a sample period T which is one tenth of the signal period. Now sample the acquired waveform at a period of T/5. Consider the acquired waveform to be constant between sample points. Plot the two waveforms and see that this is what you expect.
Use the FFT to compute the magnitude spectrum of the signal having the higher sampling frequency of 5/T Hz. Determine the frequency array and plot the first half of the magnitude spectrum as a function of frequency with the proper scaling of the vertical and horizontal axes. How many frequencies are present in the graph? Plot the magnitude spectrum of the zero order hold and compare the magnitude to the magnitude of the frequencies present to the zero order hold spectrum. Compare your results to that of Figure 3.14 (3rd ed.) of the text. Predict the frequencies that should be present and compare these values to those indicated in your magnitude spectrum plot. Why was the graph plotted over only half of the data?
clear all
hold on

Answers (1)

Christopher McCausland
Christopher McCausland on 15 Mar 2021
Hi Ketan,
I have ran the code an everything looks corrrect to me.
If I understand the question correctly you are asking more about the FFT thamn the code, why should only the first half of the FFT is plotted? And what frequencies are present? In terms of the FFT have a look at the documentation to do so, this should give you an indication of where the frequecny nulls and spikes are.
In terms of the duplication again the documentation will explain what is happening but the incredibly short explination is that the FFT process will mirror and duplicate the freqencies at y = +- (nyquest frequency * n) considering a double sided spectrum where 'n' is a positive integer. There is a lot of information out there about why this happens and I would encourage you to go and read up. The topic is fascinating!
I hope this gives you more insight to the question,
Ketan Shende
Ketan Shende on 15 Mar 2021
Many thanks for your reply. My question is that other than the peak at 10Hz in the FFT plot, I should be getting peaks at 90Hz and 110HZ as well as 190 Hz and 210 Hz that I am not getting.
Christopher McCausland
Christopher McCausland on 16 Mar 2021
Can you share the code you are using to compute and plot your FFT? I suspect that is where the problem is. You are correct in expecting those values for a 10 Hz sine wave.

Sign in to comment.


Find more on Fourier Analysis and Filtering 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!