matlab怎么用fsolve函数解非线性方程组
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
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
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询