Matlab: ginput in GUI in a plot

1.5k views Asked by At

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.

1

There are 1 answers

1
matlabgui On

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);