How is it possible to get, directly from the Matlab command window, the position (i.e. the coordinates) of an object (e.g. an arrow, a rectangle or sim.) that I have drawn on a plot?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can usually do this using the handle graphics properties. For example:
Make a plot
Then get the actual values of the points
x = get(h,’xdata’)
y = get(h,’ydata’)
Different types of objects have different properties, sometimes you have to explore. In that case this syntax is useful.
A final useful tidbit is the
gco(“get current object”) function, which provides the handle of the last item that you plotted or manually clicked on. This can help if you’re not sure where the plotted item came from.Edit:
To find all of the properties which are descendents of an object, use either
findobj, orfindall. For example:This call removes some common UI annotations
(Presumably the last example could be improved with a properly designed regexp, but I can’t seem to get that working right now.)