How to wait for uifigure to resize properly?

8 views (last 30 days)
I am building a rather complex program in appdesigner, which contains axes showing a map. I had difficulties to make sure that the map always stays at the same location whenever I resize the app and whenever I zoom in or out the map shown. I decided to control the resizing behaviour of the uifigure in which I adjust the x,y limits of the uiaxes. I have the following problem:
In the first step the resize function gets the position of a uipanel in which the uiaxes is situated. In the next step this position is used to adjust the position of the uiaxes. It seems that the position is wrong as the resizing of the uipanel is probably not complete. I added the following code to wait for the uifigure resizing and it worked:
The problem is that I have to wait for 1 second (not possible to set less than 1 second) before the plot is updated.
My questions:
  1. Why is the resizing function run before all the uifigure components are resized properly?
  2. How to wait for the resizing? (1 second might not be enough once the uiaxes contains a lot of data)
Effect of uiwait:
Peter Valent
Peter Valent on 7 May 2021
I tried this but you have to set a property on which change you are waiting. The problem is that I dont know how to say whether all the uifigure children has alrady been resized. What if they are before the code reaches waitfor() function. Then the program would stuck there and it would wait until next change in the unknown property (probably position) happens.

Sign in to comment.

Answers (0)


Find more on Maintain or Transition figure-Based Apps 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!