# Wave Upward Zero Crossing Function

3 views (last 30 days)
WeiHua Huang on 1 Aug 2019
Answered: Ajay Pattassery on 5 Aug 2019
Hello, I downloaded the ''Wave Upward Zero Crossing Function'' file provided by the official website. I want to use crosslevel='mean' for calculation, but there is always an error message, such as an attached file. I don't know how to adjust it. I hope you can reply to me. Thanks a lot.

Ajay Pattassery on 5 Aug 2019
The variable len3 is defined in the following loop.
if xDetrended(1,1)==0 & xDetrended(2,1)>0
len3=1;
end
if (xDetrended(1,1)==0 & xDetrended(2,1)<0) | (xDetrended(1,1)~=0)
for i=1:N-1
if xDetrended(i,1)<0 & xDetrended(i+1,1)>0
len3=i;
break
end
end
end
If you examine the logic of the loop, the author tries to find the location where the signal rises and crosses zero. That is the author checks xDetrended (which is your signal x minus it’s mean) and find the first location where the signal rises from 0 to a positive value or from a negative value to a positive value.
So, in your case the signal is either not rising from a negative value to a positive value(there by crossing zero)or does not start from zero and rises to a positive value. Verify whether your input signal after mean adjustment holds any of these conditions.