Perhaps the order in the code is wrong. The functions must all be at the end of the script for included functions to work.
This runs without error when I run i t here —
fun = @(L)f(7, L, bl1, bl2, bl3, bh2, bh1, Ltot, MLratio);
[L, fval, info, output] = fzero(fun, [0, Ltot]);
function retf = f(pH, L, bl1, bl2, bl3, bh2, bh1, Ltot, MLratio)
M = Mtot / (1 + bl1*L + bl2*bl1*L^2 + bl3*bl2*bl1*L^3);
Ltot_calculated = L + bl1*M*L + 2*bl2*bl1*M*L^2 + 3*bl3*bl2*bl1*M*L^3 + bh2*H^2*L + bh1*H*L;
retf = Ltot - Ltot_calculated;
Experiment to get different results.