matlab怎么用fsolve函数解非线性方程组

2025-06-27 23:29:46
推荐回答(1个)
回答1:

function F = myfun(x)
F = x*x*x-[1,2;3,4];
Save this function file as myfun.m somewhereon your MATLAB path. Next, set up an initial point and optionsand call fsolve:
x0 = ones(2,2); % Make a starting guess at the solution
options = optimoptions('fsolve','Display','off'); % Turn off display
[x,Fval,exitflag] = fsolve(@myfun,x0,options)
The solution is
x =
-0.1291 0.8602
1.2903 1.1612

Fval =
1.0e-009 *
-0.1621 0.0780
0.1167 -0.0465

exitflag =
1
and the residual is close to zero.
sum(sum(Fval.*Fval))
ans =
4.8133e-20