在matlab中求解非线性方程组
来源:百度知道 编辑:UC知道 时间:2024/05/10 08:38:09
clear
syms r l s
[r l s]=solve(r*sin(pi/3)-sqrt(l*l-(r*cos(pi/3)-s)^2)-11,r*sin(13*pi/36)-sqrt(l*l-(r*cos(13*pi/36)-s)^2)-11,r*sin(14*pi/36)-sqrt(l*l-(r*cos(14*pi/36)-s)^2)-11)
Warning: Explicit solution could not be found.
> In C:\MATLAB6p1\toolbox\symbolic\solve.m at line 136
In C:\MATLAB6p1\toolbox\symbolic\@sym\solve.m at line 49
r =
[ empty sym ]
l =
[]
s =
[]
没有解析解就求数值解吧
%----------------
function rls
clc;clear;
x0=[9 8 7]'
[r l s]=fsolve(@fun,x0,optimset('fsolve'))
function f=fun(x)
r=x(1);l=x(2);s=x(3);
f1=r*sin(pi/3)-sqrt(l*l-(r*cos(pi/3)-s)^2)-11;
f2=r*sin(13*pi/36)-sqrt(l*l-(r*cos(13*pi/36)-s)^2)-11;
f3=r*sin(14*pi/36)-sqrt(l*l-(r*cos(14*pi/36)-s)^2)-11;
f=[f1;f2;f3];
%--------------------
fsolve对初始值很依赖,你可以估计出初始值,替换掉x0=[9 8 7]'
运行结果:
x0 =
9
8
7
Optimizer appears to be converging to a point which is not a root.
Norm of relative change in X is less than max(options.TolX^2,eps) but
sum-of-squares of function values is greater than or equal to sqrt(options.TolFun)
Try again with a new starting guess.
r =
12.71365365645982 -50.89012865480433i
0.60829675724599 -50.76933281456269i
5.13018322213762 - 0.26838162173222i
l =<