# How to find distance between different points in a dataset as shown in scatter plot

2 views (last 30 days)

Show older comments

Hi,

This is my scatter plot data of 5 simulated points and data in blue is my reference point and I want to compute the distance of this blue data from other data set one by one. As all data sets are of equal dimension [1x51] and when I am computing the distance then it is giving me error of Sub-scripted assignment dimension mismatch.

I have attached the ns.mat file and I want distance matrix with distance of (1 from 2),(1 from 3),(1 from 4),(1 from 5). Need your guidance.

if true

for time = 0:0.2:10

for i=1:numData

for j=1:len_data

% Get first sensor x and y coordinates

tx = [ns(1).x];

ty = [ns(1).y];

% Compute distances

distance_nhood(i,j) = sqrt((tx- ns(i).x(j)).^2 + (ty- ns(i).y(j)).^2);

% If distance is less than 5, draw a line to it.

% First find which nodes are closest.

neighbourNodes = find(distance_nhood < 5);

.............

%%coding continue

.............

end

end

connMatrix = ( distance_nhood< txRange);

% Get the number of reachable neighbors

neighborNodes = find(neighbourNodes (1, :) == 1); % logic to think

% Get the unreached neighbors

neigbborNodes = intersect(neighborNodes, find(visited(:) == 0));% logic to think

end

##### 4 Comments

Brendan Hamm
on 4 Feb 2016

### Answers (0)

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!