Borrar filtros
Borrar filtros

DFT of sine wave

14 visualizaciones (últimos 30 días)
Magdalena Bartoszek
Magdalena Bartoszek el 29 de Abr. de 2020
Respondida: Raunak Gupta el 3 de Mayo de 2020
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 comentario
Sindar
Sindar el 30 de Abr. de 2020
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?

Iniciar sesión para comentar.

Respuestas (1)

Raunak Gupta
Raunak Gupta el 3 de Mayo de 2020
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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by