# FFT of discrete signal .Should use nextpow2 or not

13 visualizzazioni (ultimi 30 giorni)
632541 il 21 Apr 2021
Commentato: Star Strider il 2 Mag 2021
Hi ,
Number of samples= 50000 samples.
m=[ 0 54 ...................................................]
m is the discrete signal samples .Has length of 50000
Is this code correct for the signal which has 50000 samples?
Do I use nextpow2 function?
When I used it I am getting wrong frequency components in FFT.
Here is the code i have written .
m=[ 0 54 ...................................................]; 50000 samples are there .
fs=50000000; %Sampling frequency
nfft=length(m);
%nfft=2^nextpow2(nfft);
X=fft(m,nfft); %FFT of the signal
X=X(1:nfft/2);
%take magniutde
mx=abs(X);
f=(0:(nfft/2)-1)*fs/nfft; %Frequency range
figure(1);
n=50000;
t=0:1:(n-1);
plot(t,m);
title('Multisine')
xlabel('Samples')
ylabel('Amplitude');
figure(2)
plot(f,mx);
title('FFT of signal')
xlabel('Frequency')
ylabel('Amplitude');
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Star Strider il 21 Apr 2021
Using nextpow2 is not necessary. It will make the fft calculation a bit more efficient, and it will increase the frequency resolution. See the documentation section on Computational Efficiency for an extended discussion.
##### 6 CommentiMostra 4 commenti meno recentiNascondi 4 commenti meno recenti
632541 il 2 Mag 2021
Thanks Star Strider
Star Strider il 2 Mag 2021
As always, my pleasure!

Accedi per commentare.

### Categorie

Scopri di più su Spectral Measurements in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by