Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
% function [I X] = changesign(a)
% X is indexed zerocrossing (may not be an element of a)
% I is the integer index of 'a' greater than X
% CAUTION: a must be monotonic !
function [I, X] = changesign(a)
a = rowvec(a);
[~, sz1] = size(a);
if sz1 > 1
if min(a) >= 0
I = 1;
X = a(1);
elseif max(a) < 0
I = sz1;
X = a(I);
else
b(1:(sz1-1)) = a(2:sz1);
tst = a(1:(sz1-1)).*b;
[X, Itmp] = min(tst);
I = Itmp + 1;
end
else
X = 0;
I = 1;
end