Nonlinear fval, fsolve
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello, I'm trying to solve three nonlinear equations with fsolve. When I used two is worked, but when I add another one then I've an error.
function F = mufun(x)
F = [(1./A)*(x(1)-x(2))-x(3);
(-1./A)*(x(1)-x(2)) + B*(exp((x(2)-0)./C)-1);
x(1)-D ];
Variables A,B,C,D I defined in Command Window.
The warning tales:
Warning: Trust-region-dogleg algorithm of FSOLVE cannot
handle non-square systems; using Levenberg-Marquardt
algorithm instead.
> In fsolve (line 336)
In calc (line 3)
In calc file I've:
x0=[-5;5;10];
[x,fval] = fsolve(@mufunc,x0);
Everything looks fine, but output is x = x0 and I suppose the computation is wrong.
0 comentarios
Respuestas (1)
Star Strider
el 11 de Abr. de 2021
Pass ‘A’-‘D’ to ‘mufun’ as extra arguments:
function F = mufun(x,A,B,C,D)
F = [(1./A)*(x(1)-x(2))-x(3);
(-1./A)*(x(1)-x(2)) + B*(exp((x(2)-0)./C)-1);
x(1)-D ];
end
then call it as:
x0=[-5;5;10];
[x,fval] = fsolve(@(x)mufun(x,A,B,C,D),x0);
Also, note that the function is called ‘mufun’ however it is passed to fsolve as ‘mufunc’.
I am surprised that these did not throw errors, so perhaps everything exists inside another function that is over-the-horizon to us, or that the code that was run was not the code that was posted.
0 comentarios
Ver también
Categorías
Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!