DFT of sine wave

14 次查看(过去 30 天)
Magdalena Bartoszek
Hello,
I have to calculate the DFT of the following signals sampled at 32 kHz. Plot the magnitude, phase, real and imaginary parts of the DFT coefficients.
I know that to generate plots I have to use these functions: abs, angle, real, imag
I really could use some help.
The given signal is: x = sin(2pi*8000*t + pi/8), signal length: 8 samples
I am able to create function that would be without that 'pi/8' part, no idea how to add this to my function :/ ..
As far as I am concerned, the function without my problem looks like:
n=8
fs=32000
fsin=8000
A=1
df=(2*pi)
k=0: n-1;
x=A*sin((2*pi)*fsin.*k/fs + df);
X=fft(x);
fr=k*fs/n;
figure
subplot(312)
stem(fr, real(X))
title("real");
subplot(311)
stem(fr, imag(X))
title("imaginary")
But unfortunately I have no idea how to add the pi/8 part..
Thanks in advance for every hint..
  1 个评论
Sindar
Sindar 2020-4-30
It looks like you have added the pi/8, what's the problem? Are you trying to write an analytic expression for the fourier components?

请先登录,再进行评论。

回答(1 个)

Raunak Gupta
Raunak Gupta 2020-5-3
Hi,
It looks like ‘df’ in the above code can be set to ‘pi/8’ to represent time shift in original signal. Other than that everything looks fine.

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by