How to find distance between different points in a dataset as shown in scatter plot
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Brendan Hamm
le 4 Fév 2016
You are trying to assign to a scalar element of distance_nhood an entire vector and this is a dimension mismatch. The reason for this is that tx and ty are both vectors and not the first node.
Réponses (0)
Voir également
Catégories
En savoir plus sur Descriptive Statistics and Visualization dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!