Spline interpolation of spectral peaks

Hi,
I am trying to use interpolation to detect an FFT peak between bins however my interpolation results in the same peak as the FFT. I am inputting a 50Hz sine wave.. Sampling freq is 6500hz and I have 2048 sample points. There fore my bin freq is 3.17hz which multipled out gives me a 50.8hz nearest bin frequency which is what my code is giving me. I am trying to see where my interpolation code is going wrong and not giving me a peak at 50hz
Thanks in advance!
Fs =6500; % Sampling frequency
Y=SINWAVTest;
T = 1/Fs; % Sampling period
L = length(Y); % Length of signal
t = (0:L-1)*T; % Time vector
t2 = flipud(rot90(t));
y2 = Y; %+ 2*randn(size(t2));
y2 = y2;% - mean(y2);
y3 = fft((y2))
P2 = abs(y3/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
%%Interpolated
T_mean = (t(L)-t(1))/(L-1);
t_u = t(1):T_mean:t(L);
yy = interp1(t,Y,t_u,'spline');
y4 = fft(yy)
Psd_i=abs(fft(yy)).^2/(L*T_mean)
fr=[-ceil((L-1)/2):floor((L-1)/2)]/(L*T_mean);
Psd_a=abs(nedft(Y,t2,fr)).^2/(L*T_mean);
P1I = Psd_i(1:L/2+1);
P1I(2:end-1) = 2*P1I(2:end-1);
%Plot time-domain signal
subplot(4,1,1);
plot(t, Y);
ylabel('Amplitude'); xlabel('Time (secs)');
axis tight;
title('Shaker Input Signal');
subplot(4,1,2);
plot(1000*t(1:1000),y2(1:1000))
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('t (milliseconds)')
ylabel('X(t)')
subplot(4,1,3);
plot(f,P1)
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')
%ylim([0,2000]);
subplot(4,1,4);
plot(f,P1I,'r')
title('Interpolated FFT')
xlabel('f (Hz)')
ylabel('|P1(f)|')
%ylim([0,2000]);

Antworten (0)

Produkte

Version

R2006a

Gefragt:

am 6 Mär. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by