All, Can anyone tell me how to find number of zero crossing (i.e. number of time signal changes sign) in matlab? Regards ...
Is this thread worth a thumbs up?
|
All, Can anyone tell me how to find number of zero crossing (i.e. number of time signal changes sign) in matlab? Regards |
|
|
|
use the sign command and find the number of transitions. Mandar --- s7jid <> wrote: > All, > > Can anyone tell me how to find number of zero crossing (i.e. number > > of time signal changes sign) in matlab? > > Regards ===== ------------------------------------- Its not life that weighs us down, Its how we carry it. ------------------------------------ __________________________________ |
|
Try this. count = 0; thresh = 0; for(i=0:signal_length){ if(sig[i+1]>thresh && sig[i]<=thresh) count++; else if(sig[i+1]<thresh&& sig[i]>=thresh)count++; end; end; } count/=2; #8216;Count#8217; will have the numberof #8216;zero crossings#8217;. Bye Balaji Srinivasan -----Original Message----- From: s7jid[mailto:] Sent: Sunday, January 04, 20047:40 PM To: Subject: [matlab] Zero-Crossing.. All, Can anyone tell me how to find number of zerocrossing (i.e. number of time signal changes sign) in matlab? Regards _____________________________________ /groups.php3 Yahoo! Groups Sponsor ADVERTISEMENT --------------------------------- Yahoo!Groups Links · To --------------------------------- |
|
one way is this function [n] = zc(x) function zcr=zcr(x,dur) [nf,len]=size(x);
best regards >From: "s7jid" The new MSN 8: smart spam protection and 2 months FREE* |
|
If you want to avoid for loop the following code is equivalent to balaji's code thresh = 0; N = length(sig); zc = (sig >= thresh) - (sig < thresh); count = sum((zc(1:N-1) - zc(2:N)) ~= 0); > Date: Mon, 5 Jan 2004 17:42:37 -0800 (PST) > From: balaji srinivasan <> > Subject: RE: Zero-Crossing.. > Try this. > > count = 0; > > thresh = 0; > > for(i=0:signal_length){ > > if(sig[i+1]>thresh && > sig[i]<=thresh) count++; > > else if(sig[i+1]<thresh&& > sig[i]>=thresh)count++; > > end; > > end; > > } > > count/=2; > > #8216;Count#8217; will have the numberof #8216;zero > crossings#8217;. > > Bye > > Balaji Srinivasan > > > -----Original Message----- > From: s7jid[mailto:] > Sent: Sunday, January 04, 20047:40 PM > To: > Subject: [matlab] Zero-Crossing.. > > All, > > Can anyone tell me how to find number of > zerocrossing (i.e. number > of time signal changes sign) in matlab? > > Regards __________________________________ |