Interactive rectangle on UIAxes for user to choose a region

6 views (last 30 days)
I have a dataset with scattered points that I plot on a UIAxes. The idea is to let the user draw a rectangle over the UI Axes only ( not the whole figure) and select a region so that it can be processed further.
f = app.UIFigure;
f.Units = 'normalized';
pos = rbbox;
The code above is what I tried. The first problem that i see is that waitforbuttonpress opens a new figure and does not operate on the app figure or the axes. What should be the way to get this working?

Accepted Answer

Walter Roberson
Walter Roberson on 27 May 2022
Edited: Walter Roberson on 30 May 2022
Walter Roberson
Walter Roberson on 10 Jun 2022
I just successfully tested this code:
fig.WindowButtonDownFcn = @(src,event)uiresume(src);
out = uirbbox(fig);
Where uirbbox is a modified version of Mathwork's rrbox that expects a uifigure as the first parameter.
function finalRect = uirbbox(f, initialRectangle, anchorPoint, step)
f (1, 1) matlab.ui.Figure
for the chain of if nargin == add 1 to each of the counts, so like
if nargin == 1
initRect = [];
fixedPoint = [];
stepSize = [];
Then comment out
f = gcf;
With f now being a parameter that is a uifigure, and with the gcf commented out, and with the argument count incremented by 1 as appropriate... then it works.
... It does, however, take remarkably long to activate.

Sign in to comment.

More Answers (0)


Find more on Develop Apps Using App Designer in Help Center and File Exchange




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by