Calculating global nearest neighbour (GNN) in Matlab
5 次查看(过去 30 天)
显示 更早的评论
I have two data matrix. One is original data and another is measured data of radar sensor. I want to find out global nearest neighbor (GNN) of the original data from the measured data. I have already calculated the Local nearest neighbor and posted the m file below. My question is how to change it in to Global nearest neighbor.
Number_of_object = 5;
Measured_data = f_range_m(1:numSuperpulsesPerCycle_g:length(timeline_ms),:);
Original_data = OrgiRange(1:numSuperpulsesPerCycle_g:length(timeline_ms),:);
Result_Range= nearest_Distance(Original_data,Measured_data, Number_of_object);
m file for the nearest_Distance (Local nearest neighbor) is give below
function [ res ] = nearest_Distance( Original_data, Measured_data, Number_of_object)
res=nan(size(Original_data,1),Number_of_object);
for ix = 1:Number_of_object
%dist = abs(bsxfun(@minus,Measured_data,Original_data(:,ix)));
dist = abs(bsxfun(@minus,Measured_data,Original_data(:,ix)));
[~,col] = min(dist,[],2);
res(:,ix) = diag(Measured_data(:,col));
end
end
1 个评论
Jacobo Levy Abitbol
2016-6-6
Check Munkres algorithm for rectangular matrices in file exchange and apply it to your distance matrix to get the GNN optimal assignment
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!