Length=100;
Width=100;
Node_number=5;
For I=1: Node_number
Node (I)=x Width * rand.
Node (I), y=Length * rand;
Node (I). D=Node (I) x ^ 2 + Node (I), y ^ 2;
End
Target. X=Width * rand;
Target. Y=Length * rand;
X=[];
Z=[];
For I=1: Node_number
[d1, d2]=DIST (Node (I), the Target).
D1=d1 + SQRT (5) * randn;
X=[X; Node (I) X, Node (I), y];
Z=[Z] d1;
End
H=[]; B=[];
For I=2: Node_number
H=[H; 2 * (X (I, 1), X (1, 1)), 2 * (X (I, 2) - (1, 2) X)];
B=[b, Z (1) ^ 2 - Z (I) ^ 2 + Node (I), D - Node (1). D];
End
Estimate=inv (H '* H) * H * b;
Est_Target. X=Estimate (1); Est_Target. Y=Estimate (2);
Figure
hold on; Box on; The axis ([0, 100, 100]);
For I=1: Node_number
H1=plot (Node (I) x, Node (I), y, 'ko', 'MarkerFace', 'g', 'MarkerSize', 10);
The text (the Node (I). X + 2, Node (I). The y, [' Node ', num2str (I)));
End
H2=plot (Target x, Target. The y, 'k ^', 'MarkerFace', 'b', 'MarkerSize', 10);
H3=plot (Est_Target. X, Est_Target. Y, 'ks',' MarkerFace ', 'r', 'MarkerSize', 10);
The line ([Target x, Est_Target. X], [Target. J y, Est_Target. Y], 'Color', 'k');
Legend ([h1, h2, h3], 'Observation Station', 'Target Postion', 'Estimate Postion');
[Error_Dist, d2]=DIST (Est_Target, Target);
Xlabel ([' error=', num2str (Error_Dist), 'm']);
Funtion [dist, dist2]=dist (A, B)
Dist2=(A.x - B.x) ^ 2 + (A.y - B.y) ^ 2;
Dist=SQRT (dist2);
Error Erchengfa51 (line 17)
[d1, d2]=DIST (Node (I), the Target).