How do i get the Nyquist frequency from FFT and PSD?

Here is the code I was provided. I am unsure how to get the Nyquist frequency from the plot.
h_11 = 0.4*sinc(0.4*[-5:5]);
Npt=512;
fft_h_11 = fft(h_11,Npt); %FFT of filter
psd_h_11 = fft_h_11 .* conj(fft_h_11); %PSD of filter
psd_h_11_dB = 10*log10(psd_h_11); %PSD in dB
h_41 = 0.4*sinc(0.4*[-20:20]); %Impulse response, N=41
fft_h_41 = fft(h_41,Npt); %FFT of filter
psd_h_41 = fft_h_41 .* conj(fft_h_41); %PSD of filter
psd_h_41_dB = 10*log10(psd_h_41); %PSD in dB
omega = [1:Npt]*20/Npt; %frequency axis
subplot(2,1,1) %create an array of plots, 2 by 1
plot(omega,psd_h_11,omega,psd_h_41) %plot linear-scaled PSD
legend('10th order', '40th order')
title('Example 9-1 Linear Scale')
subplot(2,1,2) %Activate lower plot
plot(omega,psd_h_11_dB,omega,psd_h_41_dB) %plot logarithmic-scaled PSD
legend('10th order', '40th order')
title('Example 9-1 Logarithmic Scale')

 Accepted Answer

You do not get the Nyquist frequency from the plot, you calculate it from the data.
The Nyquist frequency is half the sampling frequency.
So:
t = ...; % Time Vector
Ts = t(2)-t(2); % Sampling Interval (Assuming Uniform Sampling)
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
I leave the rest to you.

4 Comments

As always, my pleasure.
If my Answer helped you solve your problem, please Accept it!
Is there a way to estimate it without sampling frequency and time vector? Wouldn't the power spectrum fall down at the Nyquist frequency?
If you know that the highest displayed frequency is the Nyquist frequency, you can infer the sampling frequency and sampling interval from it.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!