Question of FFFT in Matlab
Mostra commenti meno recenti
WIth the code below, I am taking the DFT of the sinewave at multiple samples in frequency domain. Why am I not seeing in DFT spectrum (second part, N=100) clear two impulses at 100 Hz?
clc;
clear all;
f = 128;
Fs = 1024;
t = (0:2047)/Fs;
x = sin(2*pi*f*t);
% calculate full sample point DFT
N = 128;
X = (1/sqrt(N))*fft(x, N);
XdB1 = 20*log10(abs(fftshift(X)));
f1 = -(Fs/2):Fs/N:(Fs/2)-1;
% plot magnitude spectrum
plot(f1, XdB1); title('DFT of sine wave at 100 Hz');
xlabel('Frequency --> f'); ylabel('Amplitude in dB'); axis([-512 511 -30 20]); hold on;
% calculate only 128 point DFT
N = 100;
deltaF = Fs/N;
X = (1/sqrt(N))*fft(x, N);
XdB2 = 20*log10(abs(fftshift(X)));
f2 = -(Fs/2):deltaF:(Fs/2)-1;
% plot magnitude spectrum
plot(f2, XdB2,'r');
xlabel('Frequency --> f'); ylabel('Amplitude in dB');
2 Commenti
Walter Roberson
il 22 Ott 2019
Fs = 1024;
That is not 100 Hz. 100Hz would be Fs = 100
f = 128;
That is not 100 Hz either; it is 128 Hz.
Daniel M
il 22 Ott 2019
Not able to test it right now, but seems odd for you to only take a 128 point fft. Just take the whole thing, should be 2047. You will probably get better resolution. By the way, your code and your comments do not match up with each other. It makes it difficult to assess what level of understanding you have of this process.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Spectral Measurements in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!