필터 지우기
필터 지우기

is this code is right? this code is for trilateration it shows error.

조회 수: 3 (최근 30일)
This code is shows error at line 22 and 29
warning is : matrix is singular to working precision.
is this code is right if not please give suggetions..
function [ x, y ] = two_tri(x1, x2, x3, y1, y2, y3, d1, d2, d3)
%2-D trilateration function
% Inputs: Readers 1-3 (x,y) and Distances to Tag
%
% x_n1 = (d1^2 - d2^2)-(x1^2 - x2^2)-(y1^2 - y2^2)*2*(y3 - y1)
% x_n2 = 2*(y2 - y1)*(d1^2 - d3^2) - (x1^2 - x3^2) - (y1^2 - y3^2)
% x_d = 2*(x2 - x1)*2*(y3 - y1) - 2*(y2 - y1)*2*(x3-x1)
% x = (x_n1 - x_n2)/x_d
% y = 2;
%
x_n11 = (d1^2 - d2^2) - (x1^2 - x2^2) - (y1^2 - y2^2);
x_n21 = (d1^2 - d3^2) - (x1^2 - x3^2) - (y1^2 - y3^2);
x_n12 = 2*(y2-y1);
x_n22 = 2*(y3-y1);
d11 = 2*(x2-x1);
d21 = 2*(x3-x1);
d12 = 2*(y2-y1);
d22 = 2*(y3-y1);
x_n = [x_n11, x_n12; x_n21, x_n22];
d = [d11, d12; d21, d22];
x = x_n/d;
x = det(x);
y_n11 = d11;
y_n21 = d21;
y_n12 = x_n11;
y_n22 = x_n21;
y_n = [y_n11, y_n12; y_n21, y_n22];
y = y_n/d;
y = det(y);
x11=[x1 x2 x3 x];
y11=[y1 y2 y3 y];
scatter(x11,y11);
disp(x11);
disp(y11);
end

채택된 답변

Walter Roberson
Walter Roberson 2016년 6월 3일
You never use the output of your det() calls, so you should get rid of them.
  댓글 수: 3
Darshan Patel
Darshan Patel 2016년 6월 3일
it shows the error in
x_n11 = (d1^2 - d2^2) - (x1^2 - x2^2) - (y1^2 - y2^2);
that d1 is undefine
Walter Roberson
Walter Roberson 2016년 6월 3일
You cannot run the code just by pressing an F key or clicking on the Run button. You need to go to the command line and use the routine in command form, passing in the data you need. For example,
x = rand(1,3); y = rand(1,3); d = rand(1,3);
[X, Y] = two_tri(x(1), x(2), x(3), y(1), y(2), y(3), d(1), d(2), d(3))

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by