Created
May 27, 2015 18:46
-
-
Save jnkather/f10d65eb00ad45cf04b6 to your computer and use it in GitHub Desktop.
calculate distance from a given point for a cloud of points, 2D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% JN Kather 2015 | |
% calculate distance from a given point for a cloud of points, 2D | |
% cloud of points | |
Pts = rand(500,2); | |
% calculate distance from P(px|py) | |
px = 0.5; py = 0.5 | |
distance = sqrt((Pts(:,1)-px).^2 + (Pts(:,2)-py).^2); | |
% plot | |
figure() | |
hold on | |
plot(px,py,'x','MarkerSize',50,'Color',[0 0 0]) | |
scatter(Pts(:,1),Pts(:,2),25,distance,'filled') | |
hold off | |
colorbar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment