Kiko
Kiko

Reputation: 99

Matlab: ginput in GUI in a plot

I am trying to get the coordinates from a plot that is inside a GUI, I wanted to use ginput function but I don't know how to use it in a plot inside a GUI. I have seen a framework called ginputax but I have not been able to make it work. My code is like this:

f=openfig('gui_final_work');
ctrl=guihandles(f);
[x y] = ginput(1);

I have also tried:

f=openfig('gui_final_work');
ctrl=guihandles(f);
[x y] = ginputax(1,ctrl.axes1);

but both cases generate a new figure separated from the GUI. Any hint will be appreciated...Thank you in advance.

Upvotes: 0

Views: 1611

Answers (1)

matlabgui
matlabgui

Reputation: 5672

Try forcing the figure focus on your on newly opened figure:

f=openfig('gui_final_work');
figure(f)
[x y] = ginput(1);

Or try:

f=openfig('gui_final_work');
figure(gcf)
[x y] = ginput(1);

Upvotes: 2

Related Questions