两向量之间的匹配
在做雷达仿真中,用算法估计出的目标参数一般都会有误差,而且顺序不一定是与原来设定的源目标参数一定。若我们需要计算RMSE等参数去评估算法性能,此时匹配结果与目标参数向量是必要的
function [k1,k2] = Pair(k1,k2,s1,s2)
%s1, s2 are source data vector , k1,k2 are data vector to be in pair with...
% source data.
% we apply listing all combination , and compare which one is best.
S = length(s1);
% reshape all vector to column vector
s1 = reshape(s1,S,1);
s2 = reshape(s2,S,1);
% firstly match k1 and s1
P1 = perms(k1); % list all permutations of k1's elements
a = size(P1,1);
Za = zeros(a,1);
for ii = 1:a
Za(ii)=norm(P1(ii,:)'-s1);% compute the minimize distance in two vector
end
nmi = find(Za == min(Za));
k1 = unique(P1(nmi,:),'rows'); % because nmi may be more than one
% then match k2 and s2
P2 = perms(k2); % list all permutations of k2's elements
b = size(P2,1);
Zb = zeros(b,1);
for ii = 1:b
Zb(ii)=norm(P2(ii,:)'-s2);
end
nmi = find(Zb == min(Zb));
k2 = unique(P2(nmi,:),'rows');