MATLAB: Multiple roots with fzero, or an alternative to find multiple root

chebfunfzeroMATLABmultiple roots

Dear MATLAB users, I want to get several roots using "fzero" function. I also tried "chebfun" but I could not run the program. So I would highly appreciate if anyone can give me any advice:
% clear all
clc
N = 100 ;
d = 6 ;
kappa = 1 ;
lambda = linspace(0.05,0.175, N );
nu_p = linspace(0.1,0.35, N );
[Lm,NP] = meshgrid(lambda, nu_p );
cosfi = 1;
f = @(x,lambda,nu_p) ((lambda - nu_p)+(lambda*x)-cosfi.*(((sqrt((1+x)./2)).*exp(-(d*(sqrt(2*lambda*(1+x))))))).*(kappa*(sqrt((1-x)./(1+x)))-(sqrt((1+x)./(1-x )))));
for k1 = 1:length(lambda )
for k2 = 1:length(nu_p )
z(k1,k2) = fzero(@(x) f(x,lambda(k1),nu_p(k2)), 0.000000000001 );
t1 = sqrt(1+(z(k1,k2)));
t2 = sqrt(1-(z(k1,k2)));
q = sqrt(.5).*t1.*exp(-d.*sqrt(2.*lambda(k1)).*t1);
J11 = 0;
J12(k1,k2) = -q.*((1 + kappa)/2).*sqrt(1-(z(k1,k2)).^2);
J21(k1,k2) = lambda(k1) + (1/2).*q.*[(1./(2.*(1 + (z(k1,k2)))))-d.*sqrt(lambda(k1)./(2.*(z(k1,k2))))].*[(1./((1+(z(k1,k2))).^2)).*(t1./t2).*kappa + (1./(1-(z(k1,k2)).^2)).*(t2./t1)];
J22 = 0;
% Eigenvalues
Eig1 = sqrt(J12.*J21);
Eig2 = -sqrt(J12.*J21);
EigReal = real(Eig1);
EigIm = imag(Eig1);
end
end
% DeltaE = Lambda - nu_p;
Z=abs(z);
figure(1 )
mesh(nu_p,lambda, EigReal)
view(2)
% title('kd=6');
xlabel('nu_p');
ylabel('lambda');
zlabel('Z');
When I change "d" 9 or 12 there will be several roots which this code would just find the first one, and I am interested in finding Eigenvalue for those other roots also.
Thanks in advance

Best Answer

Script enclosed. You will want to bump up M and N to your 101 each. I did not test that high with this version of the script because it is not fast.
I see no evidence at all that any point has more than one root.
When I was testing the fzero() version, I was able to show that the function under consideration then did not have more than one root for fixed parameters. What I did not do is go back to check to see if the function you are passing to chebfun is the same as the one I investigated earlier.