MATLAB: Restricting domain of values fzero will try

fzero

I am using fzero along with an implementation of the gillespie algorithm to determine a parameter (I know the vale of a parameter at steady state, but now I want it proportional to another quantity, and I am using fzero to determine this constant of proportionality, alpha).
However, the simulation only works if alpha is positive, otherwise we get negative rates which mess everything up. From what I can tell, fzero is trying negative values of alpha when trying to find the zero. Is there any way I can restrict fzero to only use positive values?

Best Answer

Specify the search interval [xlower, xupper] to include only non-negative values.
fzero(fun,[xlower, xupper])