ZeroCrossing on a graph

I have to create a zerocrossing script which says when a graph passes from positive values to negative values (only this case) and then it plots a graph including all these points of zero crossing. Can someone help me with a code?

4 Comments

So... what is your question?
I'm trying to create a code but i can't do it.
Consider what happens to diff(y) and look at
doc sign
for ideas...
if true
% code
plot(sig_AP, 'y')
hold on
for i = 1:length(sig_AP)-1
if ( sig_AP(i)>0 && sig_AP(i+1)<0 )
sig_AP(i+1) = 0-sig_AP(i+1);
x = sig_AP(i);
y = sig_AP(i+1);
if ( x > y )
ZC(i) = sig_AP(i+1);
else
ZC(i) = sig_AP(i);
end
else
ZC(i) = 0;
end
end
ZC = ZC'
plot (ZC, 'k')
end
I try something like this but it doesn't work... i'm not very able with matlab..

Sign in to comment.

Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Asked:

on 18 Sep 2017

Commented:

on 18 Sep 2017

Community Treasure Hunt

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

Start Hunting!