toa.m

来自「toa代码仿真」· M 代码 · 共 19 行

M
19
字号
% This function calculates Tag's position using Least square Algorithm

function [Error] = toa(AP, Tag, time_dur, light_speed)

L = time_dur .* light_speed;
n = length(AP);
% Here we use LEAST SQUARES estimation for estimated Tag's location

for i = 2:n
    P(i-1,1) = AP(i,1);
    P(i-1,2) = AP(i,2);
end

B(1,:) = (AP(2,1)^2 + AP(2,2)^2) - L(2)^2 + L(1)^2;
B(2,:) = (AP(3,1)^2 + AP(3,2)^2) - L(3)^2 + L(1)^2;

k = (P'*P)^(-1)*P'*B*0.5;
Error = sqrt((Tag(1) - k(1))^2 + (Tag(2) - k(2))^2);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?