函数作用
输入气压高度值、待定位节点与各个锚节点的距离、锚节点位置、权重(可选),输出待测点位置
程序源码
function [p_out] = triposition_weight_Ver2(dairheight,R_calcu,baseP,varargin)
% airghight 由气压高度计算的锚节点-待测节点的相对高度,按行向量排布
% R_calcu 距离,每个时刻的若干个距离按行向量排布
% baseP 锚点位置,每个锚点坐标按行形式排列
% varargin 【可选】各锚点的位置权重,对角矩阵形式,若无则权重相同
if size(varargin,1) == 0W = 0.5*eye(3);
elseW = cell2mat(varargin);
end
[baseX_,baseY_,baseZ_] = deal(baseP(:,1),baseP(:,2),baseP(:,3));
% baseY_ = baseP(:,2);
% baseZ_ = baseP(:,3);
H = [baseX_(2)-baseX_(1),baseY_(2)-baseY_(1);baseX_(3)-baseX_(1),baseY_(3)-baseY_(1);baseX_(4)-baseX_(1),baseY_(4)-baseY_(1)];
for i=1% HX=aa = 0.5*[baseX_(2).^2+baseY_(2).^2-R_calcu(i,2).^2-baseX_(1).^2-baseY_(1).^2+R_calcu(i,1).^2;baseX_(3).^2+baseY_(3).^2-R_calcu(i,3).^2-baseX_(1).^2-baseY_(1).^2+R_calcu(i,1).^2;baseX_(4).^2+baseY_(4).^2-R_calcu(i,4).^2-baseX_(1).^2-baseY_(1).^2+R_calcu(i,1).^2];% p_out(i,:) = (pinv(H)*a)'; %伪逆求法
% (H'*H)^(-1)*H'*a;X(:,i) = (H'*W(2:end,2:end)*H)^(-1)*H'*W(2:end,2:end)*a; %左逆求法end
height = sum(W*(baseZ_-dairheight'))/trace(W);
p_out = [X;height]';
end