Prev: cannot access mcc daq USB-1298FS with matlab 2010a
Next: 3d plot of a function with two variables
From: Aino on 7 Jun 2010 16:03 Hi all! I am trying to make a code for calculating approximate entropy (Pincus 1996). Since the measure is somewhat random (personal opinion..) I compared my code with another one I found in this forum (http://www.mathworks.com/matlabcentral/newsreader/view_thread/259062#712823). I didn't get exactly the same results.. At least the logarithm is taken in a bit later point in the code than in the other code. Here's my code (cop is the signal): function AppEnt=ApproxEntropy(cop,M,r) N=length(cop); count1=0; count2=0; CIM=[]; for m=[M,M+1] Cim=NaN(1,N-m+1); for i=1:N-m+1 seg_i=cop(i:i+m-1); for j=1:N-m+1 seg_j=cop(j:j+m-1); for k=1:m if abs(seg_i(k)-seg_j(k))>r count1=count1+1; end end if count1==0 count2=count2+1; end count1=0; end Cim(i)=count2/(N-m+1); count2=0; end CIM=cat(2,CIM,sum(log(Cim))/(N-m+1)); end AppEnt=CIM(1)-CIM(2); Could you help me see if there is something wrong with it? Also, if I put random noise in to the code, it doesn't give out "a big number" (what ever that means). Also, can I use this as a cross approximate entropy if I change the seg_j to be from another signal? Thank you so much! -Aino
From: Aino on 10 Jun 2010 09:30 Well, I read that Sample Entropy would be a better than Approximate entropy, so I changed to that. Though now I have big problems of speeding it up, I guess I will post about it now.. Thanks! -Aino "Aino" <aino.tietavainen(a)removeThis.helsinki.fi> wrote in message <hujj9q$496$1(a)fred.mathworks.com>... > Hi all! > > I am trying to make a code for calculating approximate entropy (Pincus 1996). Since the measure is somewhat random (personal opinion..) I compared my code with another one I found in this forum (http://www.mathworks.com/matlabcentral/newsreader/view_thread/259062#712823). I didn't get exactly the same results.. At least the logarithm is taken in a bit later point in the code than in the other code. Here's my code (cop is the signal): > > function AppEnt=ApproxEntropy(cop,M,r) > > N=length(cop); > count1=0; > count2=0; > CIM=[]; > > for m=[M,M+1] > Cim=NaN(1,N-m+1); > > for i=1:N-m+1 > seg_i=cop(i:i+m-1); > > for j=1:N-m+1 > seg_j=cop(j:j+m-1); > > for k=1:m > if abs(seg_i(k)-seg_j(k))>r > count1=count1+1; > end > end > > if count1==0 > count2=count2+1; > end > count1=0; > end > > Cim(i)=count2/(N-m+1); > count2=0; > end > CIM=cat(2,CIM,sum(log(Cim))/(N-m+1)); > end > > AppEnt=CIM(1)-CIM(2); > > Could you help me see if there is something wrong with it? Also, if I put random noise in to the code, it doesn't give out "a big number" (what ever that means). > > Also, can I use this as a cross approximate entropy if I change the seg_j to be from another signal? > > Thank you so much! > > -Aino
|
Pages: 1 Prev: cannot access mcc daq USB-1298FS with matlab 2010a Next: 3d plot of a function with two variables |