
function crossings = zerocrossings(x,y); 
%function crossings = zerocrossings(x,y); 
% finds zero-crossings, values of x for which y(x) = 0. 
% x need not be monotonic. 

crossings = []; 
test = (y>0); 
shortlist = 1:length(y)-1; 
where = find(test(shortlist)~=test(shortlist+1)); 
for i = 1:length(where), 
  crossings = [crossings interp1(y(where(i):where(i)+1), x(where(i):where(i)+1), 0)]; 
end; 
