Clear Filters
Clear Filters

Calculating global nearest neighbour (GNN) in Matlab

4 views (last 30 days)
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 Comment
Jacobo Levy Abitbol
Jacobo Levy Abitbol on 6 Jun 2016
Check Munkres algorithm for rectangular matrices in file exchange and apply it to your distance matrix to get the GNN optimal assignment

Sign in to comment.

Answers (0)

Categories

Find more on Automotive in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!