那位知道去希尔伯特包络趋势的算法在那可以找到?下面程序中pd为零,怎么循环?fs_kHz=8
% Function to remove the trend in the hilbert envelope
%--------------------------------------------------------------------------
function [Ret] = rem_trend(h,fs_kHz);
pd = floor(fs_kHz*2/1000);
for i = 1:pd
temp = h(1:i+pd);
Ret(i) = h(i)/mean(temp);
Ret(i) = Ret(i)*h(i);
end;
for i = pd+1:length(h)-pd
temp1 = h(i-pd:i+pd);
Ret(i) = h(i)/mean(temp1);
Ret(i) = Ret(i)*h(i);
end;
for i = (length(h)-pd+1):length(h)
temp2 = h(i:length(h));
Ret(i) = h(i)/mean(temp2);
Ret(i) = Ret(i)*h(i);
end;