The key to this problem is that there is one root in each interval [n*pi,(n+1)*pi]. I'm going to assume that L > 1, otherwise the region near the origin is a special case.
function beta = find_beta(L,nRoots)
f = @(x) x*cot(x)+L-1;
beta = zeros(nRoots,1);
smallOffset = 1e-12;
for i=1:nRoots
beta(i) = fzero(f,[i*pi+smallOffset (i+1)*pi-smallOffset]);
end
Best Answer