How to loop the fsolve for various sets of parameters
Mostrar comentarios más antiguos
I have four different non linear equations to solve for 4 unknowns. The known parameters in the equations vary and i have around 1000 such sets of parameters. How to use fsolve to solve for these various parameter sets and store separate values for the unknowns (say r1,r2,r3,r4)? I am able to solve for 1 set of parameters and I am unable to figure out how to use different sets of paarameters. I tried looping in the fsolve but I am not sure how to proceed. Any help would be great!
Thanks.
%CODE FOR EQUATION SOLVING
%one set of parameters p1,p2,p3 are illustrated here
function F= eq(r)
F(1)= (62624.20783*4*(8.854e-12))-(9*r(4)*r(2)*0.01); %the value 62624.20783 is p1 (has 1000 different values)
F(2)= (46383.18112*r(2)*(0.001)*((2*r(3))+0.15))-(2*r(3)*0.15); % the value 46383.18112 is p2
F(3)= (r(3)*(1-r(4)).^(1.5))- (1.36640009); % the value 1.36640009 is p3
F(4)= r(4)-((4/3)*3.14*((r(2)).^3)*r(1));
end
%code for solving the equations
fun=@eq;
r0=[10000 1E-6 10 2E-15]; %initial guess
options = optimoptions('fsolve','Display','iter','MaxFunEvals',50000, 'MaxIter',1000);
[r,fval,exitflag,output] = fsolve(fun,r0,options);
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Mathematics 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!