function [erId, errLoc] = err_zrs(res, th, wl)


% zrs = conv(res, ones(720,1), 'valid');
% zconv = [ones(360,1); zrs; ones(359,1)];
% zrsInd = find(zconv == 0);
% 
% zrsLoc = ones(size(res));
% 
% for i = 1:length(zrsInd)
%     zrsLoc(zrsInd(i)-360:zrsInd(i)+360) = 0;
% end
% zrsLoc(1) = 1;
% zrsLoc(end) = 1;



t1 = diff(res);
% i1 = find(t1 == 1);
% i2 = find(t1 == -1);
cw = 130;
temp = ones(cw,1);
%erf = conv(abs(t1), ones(200,1), 'valid');

erf = conv(abs(t1), temp, 'valid');

erf1 = [zeros(cw/2,1); erf; zeros(cw/2,1)];

erId = find(erf1>th);

errLoc = ones(size(res));

%wl = 200;

for i = 1:length(erId)
    
    if((erId(i)-200)>0 & (erId(i)+200)< length(errLoc))
        errLoc(erId(i)-200:erId(i)+200) = 0;
    elseif((erId(i)-200)<=0)
        errLoc(1:erId(i)+200) = 0;
    elseif((erId(i)+200)>=length(errLoc))
        errLoc(erId(i)-200:end) = 0;
    end
end
errLoc(1) = 1;
errLoc(end) = 1;

end