|  | 
 
 
 楼主|
发表于 2011-5-10 16:58
|
显示全部楼层 
| 回复 6 # ChaChing 的帖子 
 谢谢你的建议,我不懂规则,那个是程序有点问题
 function [ApEn_value,C_m,C_m_1] = ApEn(data,m,r_factor)
 
 % Estimate the Aproximate Entropy (ApEn) of a data.
 % m=1 or m=2
 % r between 0.1*SD and 0.25*SD, where SD is the data standard deviation
 % N (data length) between 75 and 5000;
 % [ApEn_value] = ApEn(data,m,r);
 
 % Input variables:
 % data - data
 % m - pattern length
 % r_factor - factor of the criterion of similarity   r_factor*std(data)
 
 % Output variables:
 % ApEn_value - ApEn calculated from the data
 
 % Optional output variables:
 % C_m
 % C_m_1
 m=2;r_factor=0.3;
 %x=load('E:\Noraxon data\14严碧英\行走');
 %x=x.Data{1,1}(2501:3500,1);%周期提取
 %data=2*(x-min(x))/(max(x)-min(x))-1;%幅值归一
 N=length(data);
 % C computation for the "m" pattern.
 [C_m] = C_m_computation(data,m,r_factor);
 % C computation for the "m+1" pattern.
 [C_m_1] = C_m_computation(data,m+1,r_factor);
 
 
 % Phi’s computation.
 phi_m=mean(log(C_m));
 phi_m_1=mean(log(C_m_1));
 % Final ApEn computation.
 ApEn_value=[phi_m-phi_m_1];
 
 
 % -------------------------------------------------------------------
 function [C_im] = C_m_computation(data,m,r_factor)
 X=[];C_im=[];n_im=[];max_dif=[];
 N=length(data);
 
 % Construction of the X’s vectors.
 for j=1:N-m+1
 X(j,:)=data(j:j+m-1);
 end
 
 % C computation.
 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(data)
 n_im=n_im+1;
 end
 end
 C_im=[C_im; n_im/(N-m+1)];
 end
 这个是更新后的程序,其中的输入是一组一维数据
 | 
 |