Optimizing zero-crossing indices

19 views (last 30 days)
filename='AAA'
load = xlsread(filename,1,'C:C');
extension = xlsread(filename,1,'D:D');
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
zxidx= zci(load);
figure
plot(extension, load)
hold on
plot(s(zxidx),l(zxidx),'o')
Capture.PNG
As you can see from the plot, it generally capture the targeted data well. But they are not correct.
I feel like I need to control the zero-crossing indexing function, but I am challenging how to even fine-tune it further.
Thank you.

Accepted Answer

Star Strider
Star Strider on 19 Jan 2019
I wrote ‘zci’ so I will do my best to help you with it.
It contains no error checking, so there can be a ‘wrap-around’ effect because of circshift, such that if the end of a sequence is on one side of zero and the beginning of the sequence is on the other, ‘zci’ will consider this a true zero-crossing, even though it is not. That may be what you are seeing. The solution is simply to delete the last index.
(I may consider writing a full function version of it as a File Exchange contribution that checks the ends of the sequence, and automatically deletes the end index in that event. The anonymous function version does not have that option.)
  6 Comments
Yash Patel
Yash Patel on 12 Mar 2022
How can we find the value of zero crosssing points in the form of array.
Star Strider
Star Strider on 12 Mar 2022
The ‘zci’ function should produce an array (vector) of indices.
The exact values of the zero-crossings require interpolation of both the independent and dependent variables in a narrow range of indices around each index returned by ‘zci’. This requires a loop.
.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!