MATLAB: Struggling to use fzero on this function

fzero

I am trying to solve for when y=0 with u as the variable for the function below.
When I try v= fzero(@(u) velocity(u,-1,250E-6, 0.13))
MATLAB says:
FZERO requires at least two input arguments or a structure with valid fields.
Any ideas?
function y=velocity(u,z,Ro,H)
p_sat = 2.3393E3; Patm = 100E3; rho_f = 998.21; g = 9.81; Pl = Patm-rho_f*g*z; gamma = 7.28E-2;
p =[Pl-p_sat 2*gamma 0 -(Patm+rho_f*g*H)*Ro^3]; R = roots(p); % get all roots of p R = R(imagĀ®==0); % only keep real roots
Vb=(4.*pi.*R^3)./3;
g = 9.81; rho_f = 998.21; temp = 20+273; R_g = 8.3145; y_air = 1-((p_sat)./(Pl.*((Ro./R).^3))); y_water = 1-y_air; Mr = (28.9647./1000).*y_air + (18./1000)*y_water; Pb = Pl+((2.*gamma)/R); rho_b = (Pb./(R_g.*temp)).*Mr; mu = 0.0010005; d = 2.*R;
Re =((rho_f*u*d)/mu) cd =(24/Re)*(1+0.15*Re.^0.687)
y=Vb.*g.*(rho_f-rho_b)-cd.*((pi.*d.^2)/4)*((rho_f*u.^2)/2)
end

Best Answer

You need to tell fzero either a starting point or an interval in which you know a zero exists. This means fzero needs to be called with at least two inputs (the second of which is a scalar or a 2-element vector) or if you call it with one input that input needs to be a problem structure that contains that information.