Created
August 19, 2013 12:10
-
-
Save pikipity/6268454 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [ XPhase,f,Imag,t,f_OGZ,maxf_emdvalue ]=IF_hilbert(x,fs) | |
%x is the signal that will be analysised | |
%fs is sample frequency | |
%XPhase is instanepus phase | |
%f is instaneous phase | |
%t is the time string | |
%f_OGZ is the mean frequency | |
%maxf_emdvalue is the frequency whose property is maximum. | |
if length(x)<2 | |
error('The length of x is too short') | |
end | |
Ts=1/fs; | |
x=hilbert(x); | |
XPhase=phase(x); | |
for n=1:length(x) | |
t(n)=n*Ts; | |
Imag(n)=abs(x(n)); | |
if n==1 | |
f(n)=1/2/pi*(XPhase(2)-XPhase(1))/Ts; | |
elseif n==length(x) | |
f(n)=1/2/pi*(XPhase(n)-XPhase(n-1))/Ts; | |
else | |
f(n)=1/2/pi*(XPhase(n+1)-XPhase(n-1))/2/Ts; | |
end | |
end | |
f_OGZ=sum(f)/length(f); | |
f_range=0:1:100; | |
f_pro=hist(f,f_range); | |
maxf_emd_pro=max(f_pro); | |
maxf_emd_pro_index=find(f_pro==maxf_emd_pro); | |
maxf_emdvalue=f_range(maxf_emd_pro_index); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment