# Sampling of a Sine wave.

107 ビュー (過去 30 日間)
Ketan Shende 2021 年 3 月 15 日
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
clc
t=0:0.01:1;
y=sin(2*pi*10*t);
figure(1)
plot(t,y)
hold on
t1=0:0.002:1;
y1=sin(2*pi*10*t1);
t2=t1(1:5:end);
figure(1)
plot(t2,y,'*')

サインインしてコメントする。

### 回答 (1 件)

Christopher McCausland 2021 年 3 月 15 日
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,
Christopher
##### 2 件のコメント表示非表示 1 件の古いコメント
Christopher McCausland 2021 年 3 月 16 日
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.
Christopher

サインインしてコメントする。

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!