Phase shift

function ph=phaseh(x,y);
%
% Instantaneous phase between two signals x and y.
% ph – Instanatneous phase of the second channel y
% relative to the first one [Degrees] %
% Ā© 2011 Michael Feldman
% For use with the book “HILBERT TRANSFORM APPLICATION
% IN MECHANICAL VIBRATION”, John Wiley & Sons, 2011
%
x=x(:); y=y(:);phase shift
xH = hilbfir(x);
yH = hilbfir(y);

alpha= (x.*y+xH.*yH); % Item of denominator
beta = (xH.*y-x.*yH); % Item of numerator of log.decrement xHy-xyH
ph = -180*atan2(beta,alpha)/pi; % phase shift (Degrees)

return
x=cos(0.24*(1:1024))’;
y=cos(0.24*(1:1024)+pi/4)’;
ph=phaseh(x,y);
figure(1);
plot(ph)