Hi,
This is a simple solution for you:
--------------------------------------------------
function [x0,XTOL]=zercros(F,LLIM,ULIM,XTOL,YTOL)
TOL=(ULIM-LLIM)*XTOL;
n=0;
J=[];
while isempty(J) & n<100
x=linspace(LLIM,ULIM,round(1/TOL));
y=eval([F '(x)']);
ay=abs

; % absolute value
J=find(ay<YTOL);
TOL=TOL/2;
n=n+1;
end
dy=diff

; % derivative
J1=find(dy(J)); % nonzero derivatives at detected points
x0=x(J(J1));
XTOL=TOL/((ULIM-LLIM);
______________________________
Note that this method may give you less zero crossings than exists because it designed to find at least one or give up after 100 iterations. If you find that XTOL have changed, you better run it again with a twice value of the resulted XTOL to find if there are other solutions in the region.
Usually you will get for each zero crossing to values of x0, one just before and the second just after it.
Joe
BSTEX - Equation viewer for Matlab