Created
February 10, 2016 23:04
-
-
Save debidatta/b55869c94c4882a78708 to your computer and use it in GitHub Desktop.
MATLAB script to select points from a 3D scatter plot by clicking on it
This file contains hidden or 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
function [pts] = getpts3d(x, y, z, n) | |
%% getpts3d Select points from a 3D scatter plot by clicking on plot | |
% x - Vector of X coordinates | |
% y - Vector of Y coordinates | |
% z - Vector of Z coordinates | |
% n - Number of points needed to be selected | |
% pts - Returns a n x 3 matrix of selected points | |
h = figure; | |
scatter3(x,y,z); | |
pts = zeros(n,3); | |
datacursormode on | |
dcm_obj = datacursormode(h); | |
for i=1:n | |
display(sprintf('Click on figure for point %d',i)) | |
waitforbuttonpress; | |
f = getCursorInfo(dcm_obj); | |
pts(i,:) = f.Position; | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was useful! Thanks!