harithota20
Junior Member level 2
how to find the no. of zero crossings of a random signal in matlab.
i am using this code, but i am not getting the exact answer,
function zc=zcr(sig,N)
clear all;
fid=fopen('C:\Documents and Settings\Measurement lab\Desktop\imf1.txt');
data=fread(fid,1000,'bit4');
plot(data(1:100));
grid on;
sig = data;
thresh = 0;
N = length(sig);
zc = (sig >= thresh) - (sig < thresh);
count = sum((zc(1:N-1) - zc(2:N)) ~= 0);
i am using this code, but i am not getting the exact answer,
function zc=zcr(sig,N)
clear all;
fid=fopen('C:\Documents and Settings\Measurement lab\Desktop\imf1.txt');
data=fread(fid,1000,'bit4');
plot(data(1:100));
grid on;
sig = data;
thresh = 0;
N = length(sig);
zc = (sig >= thresh) - (sig < thresh);
count = sum((zc(1:N-1) - zc(2:N)) ~= 0);
Last edited: