fzero returns "Too many input arguments"
Mostrar comentarios más antiguos
Function code:
function retf = f(pH, L, bl1, bl2, bl3, bh2, bh1, Ltot, MLratio)
Mtot = MLratio * Ltot;
H = 10^(-pH);
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;
end
Want to optimize retf to 0 at specified pH values by varying L
clear all vars
clc
bl1 = 10^(6.78);
bl2 = 10^(11.78);
bl3 = 10^(14.9);
bh2 = 10^(15.9);
bh1 = 10^(9.83);
Ltot = 0.04;
MLratio = 1/3;
'speciation_ni_his_varied_pH_function.m';
fun = @(L)f(7, L, bl1, bl2, bl3, bh2, bh1, Ltot, MLratio);
[L, fval, info, output] = fzero(fun, [0, Ltot]);
L / Ltot
L is an element of 0:Ltot
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Optimization en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!