- #1
Luongo
- 120
- 0
I'm doing some research with MATLAB, where i have a simple chirp. y = sin(x.^2)
i take the FFT of the chirp, set the upper half of the FT of the signal to 0, and take the IFFT of this to recover the original chirp y with real and imaginary parts.
then i use the formula for calculation of the instantaneous frequency:
(s1.*ds2 - s2.*ds1)./(s1.^2 +s2.^2)
where s1 is the real part of y, s2 is imag of y
and ds1 and ds2 are the derivatives of s1 and s2 respectively.
It turns out i get my inst. freq to be y = x. but i expected y = 2x.
Is there any reason why my inst. frequency is missing the factor of 2? I have no idea what I'm doing wrong that results in the missing factor.
thanks!
any help is greatly appreciated.
here is my MATLAB code:
function []=chirp()
x = 0:0.01:5;
y = sin(x.^2);
y = sin(x.^2)-mean(y); %eliminate DC offset subtract mean
plot(x,y,'k')
hold on
y = fft(y);
y = 2*y; %double the amplitude
y(250:end) = 0; %cut off upper half the signal
y = ifft(y);
%double amplitude of the chirp signal
s1 = real(y);
plot(x,s1, 'p')
s2 = imag(y);
%plot(x,s2, 'r')
ds1 = diff(s1)./0.01;
ds1(501) = 0;
ds2 = diff(s2)./0.01;
ds2(501) = 0;
%derivative plots:
%plot(x,ds1,'y');
%plot(x,ds2,'k');
%obtain instantaneous frequency
n = (s1.*ds2 - s2.*ds1);
d = (s1.^2 +s2.^2+ (max(s1).^2));
q = n./d;
plot(x,q, 'g')
i take the FFT of the chirp, set the upper half of the FT of the signal to 0, and take the IFFT of this to recover the original chirp y with real and imaginary parts.
then i use the formula for calculation of the instantaneous frequency:
(s1.*ds2 - s2.*ds1)./(s1.^2 +s2.^2)
where s1 is the real part of y, s2 is imag of y
and ds1 and ds2 are the derivatives of s1 and s2 respectively.
It turns out i get my inst. freq to be y = x. but i expected y = 2x.
Is there any reason why my inst. frequency is missing the factor of 2? I have no idea what I'm doing wrong that results in the missing factor.
thanks!
any help is greatly appreciated.
here is my MATLAB code:
function []=chirp()
x = 0:0.01:5;
y = sin(x.^2);
y = sin(x.^2)-mean(y); %eliminate DC offset subtract mean
plot(x,y,'k')
hold on
y = fft(y);
y = 2*y; %double the amplitude
y(250:end) = 0; %cut off upper half the signal
y = ifft(y);
%double amplitude of the chirp signal
s1 = real(y);
plot(x,s1, 'p')
s2 = imag(y);
%plot(x,s2, 'r')
ds1 = diff(s1)./0.01;
ds1(501) = 0;
ds2 = diff(s2)./0.01;
ds2(501) = 0;
%derivative plots:
%plot(x,ds1,'y');
%plot(x,ds2,'k');
%obtain instantaneous frequency
n = (s1.*ds2 - s2.*ds1);
d = (s1.^2 +s2.^2+ (max(s1).^2));
q = n./d;
plot(x,q, 'g')