Main Content


Block MATLAB command line until ROI operation is finished




wait(ROI) blocks execution of the MATLAB® command line until the operation on the ROI object ROI completes. Indicate completion by double-clicking the ROI object.


collapse all

Read an image into the workspace.

I = imread('pout.tif');

Display the image.


Create an ROI on the axes. Click and drag the mouse to create the rectangular ROI.

roi = drawrectangle;

At the command line, view the value of the Position property of the ROI.

ans = 1×4

   57.0000  146.0000  141.0000   87.0000

Call the wait method of the ROI. This blocks the command line until an operation on the ROI completes. For example, you can move the ROI, reshape it, or rotate it (if you have enabled rotation). For this example, position the cursor inside the ROI, click and drag the ROI over the image to a new location. To indicate completeness, double-click the ROI.


Back at the command line, check the value of the ROI's Position property. You can see that the values have changed to represent the new position.

ans = 1×4

   15.0000   20.0000  141.0000   87.0000

Input Arguments

collapse all

Region of interest, specified as an ROI object of one of the types listed in this table.

Introduced in R2019b