Plotting lines between X,Y coordinates after filtering by calculated distance
Mostrar comentarios más antiguos
I've calculated the distance between my X,Y coordinates (stored in "coord" a 220x2 double). Accordingly, "distance" is a 220x220 double. See the successful code in this first block.
coord = horzcat(X,Y1);
[mmm nnn] = size(coord);
nnn = mmm;
distance = zeros(mmm,nnn);
% slope = zeros(mmm, nnn);
for i = 1 : mmm
for j = 1 : nnn
scale = 8.6719;
distance(i, j) = (sqrt((coord(i, 1) - coord(j, 1)) ^ 2 + ...
(coord(i, 2) - coord(j, 2)) ^ 2))/scale;
% slope(i,j) = (coord(i, 2) - coord(j, 2))/(coord(i, 1) - coord(j, 1));
end
end
What I need to do now is output a visual confirmation. I'd like to only plot lines with a distance less than 10. Since this is just a visual confirmation, I'd like to only do it with the first column of "distance" (the distance calculations with respect to the first X,Y coordinate).
This is what I tried to do in order to get my visual confirmation, but it nearly crashed my computer. Any suggestions or links to existing forums are greatly appreciated. Thank you!
for i = 1 : mmm
for j = 1 : nnn
scale = 8.6719;
distance(i, j) = (sqrt((coord(i, 1) - coord(j, 1)) ^ 2 + ...
(coord(i, 2) - coord(j, 2)) ^ 2))/scale;
% slope(i,j) = (coord(i, 2) - coord(j, 2))/(coord(i, 1) - coord(j, 1));
distance_example = distance(:,1);
for p = 1:length(distance_example)
if distance_example < 10
plot(distance, 'bs-', 'LineWidth', 2, 'Color', 'b');
end
end
end
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

