|
楼主 |
发表于 2007-5-9 16:50
|
显示全部楼层
function [ApEn_value,C_m,C_m_1] = ApEn(signal,m,r_factor)
signal=6000;
m=2;
r_factor=0.35;
signal=signal(:)';
N=length(signal);
[C_m] = C_m_computation(signal,m,r_factor);
[C_m_1] = C_m_computation(signal,m+1,r_factor);
phi_m=mean(log(C_m));
phi_m_1=mean(log(C_m_1));
ApEn_value=[phi_m-phi_m_1];
% -------------------------------------------------------------------
function [C_im] = C_m_computation(signal,m,r_factor)
X=[];C_im=[];n_im=[];max_dif=[];
N=length(signal);
for j=1:N-m+1
X(j,:)=signal(j:j+m-1);
end
for j=1:N-m+1
aux1=repmat(X(j,:),N-m+1,1);
dif_aux=abs(X-aux1);
n_im=0;
for k=1:N-m+1
if max(abs(dif_aux(k,:)))<r_factor*std(signal)
n_im=n_im+1;
end
end
C_im=[C_im; n_im/(N-m+1)];
end
结果:
>> Warning: Divide by zero.
(Type "warning off MATLAB:divideByZero" to suppress this warning.)
> In E:\matlab\toolbox\matlab\datafun\mean.m at line 26
In E:\cc\data\小波包与近似熵\ApEn.m at line 32
Warning: Divide by zero.
(Type "warning off MATLAB:divideByZero" to suppress this warning.)
> In E:\matlab\toolbox\matlab\datafun\mean.m at line 26
In E:\cc\data\小波包与近似熵\ApEn.m at line 33
ans =
NaN |
|