用fsolve()函数求这个方程组的数值解比较好,具体代码如下:
1、建立方程组代码,保存为myfun.m文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function F = myfun(x)
% 待求解的方程组,x为要求解的变量,是一个1×4的向量,前三个表示坐标,x(4)为辅助变量——因为n1和n2平行,x(4)即为二者的比值
A1=[0,0,0];
B=[2,1,1];
E=[1,1,0.5];
A2=x(1:3);
BA1=A1-B;
BA2=A2-B;
BE=E-B;
n1=cross(BA1,BA2);
n2 = cross(BA1,BE);
f = x(4)*n1-n2; % 因为n1和n2平行,则此式为零向量
F = [f(1);f(2);f(3);dot(BA1,BA2)/(norm(BA1)*norm(BA2))-cos(10/180*pi)];
2、在命令窗口直接求解:
>> x0=rand(1,4); % 任意假设一个初始解
>> fsolve(@myfun,x0)
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.
x =
0.1455 0.4794 0.0727 1.2296
这个题目的解好像不唯一。