Matlab app designer gets stuck when enlarging figure (dynamic simulation)

I am using Matlab app designer to build a PID control simulator of different dynamic systems. The problem that I have is that when I enlarge figure to plot the progress of the control loop the app gets stuck, but when I keep the figure small (after dragging and dropping it without making it large) the app runs smoothly and without any problem.
Do you have an idea/solution why enlarging the figure causes the app to get stuck ?

Answers (1)

When you enlarge the figure, a resize function is called to update and propagate the new size to various graphic object.
This is decide by the MATLAB "thread scheduller". My guess is your simulation is considered as priority and never yield hand to graphic resize.
Worl around: Try to add
drawnow
command now and then, for example every n-iteration of whatever the simulation loop. Something at a frequency of about 1-10Hz would be fine I guess, without much speed penalty of your simulation.

6 Comments

Hi Bruno,
thanks you for the fast reply. For the drawnow I am already using it in my code! Furthermore at each iteration I have to update the plot and plot the system state and the control action up to iteration number K.
What happens if you run your code with the editor open, then while it's runing add a breakpoint for example at the line of "drawnow"?
I have seen similar odd things on my side that in some older MATLAB version that have been solved recently. It seems to me like MATLAB bug.
Hi Bruno,
what is the aim of adding a breakpoint at the line of drawnow? the exectuion will just stop there without any further information about the reason of getting stuck!
See if your graph get updated (sorry I forgot to say you change the App figure size before adding the breakpoint)
Bruno,, unfortunately you cannot change the figure size once you run the app. I really dont know why enlarging the UIAxes to the UIFigure width gets the app stuck!!
Odd. How do you do to obtain the screen shot pic.png? I though you would simply do the same (using the mouse to drag window right side border on the right) ?
Nevermind if you cannot do it.
Do you inspect/set 'AutoResizeChildren' property of the axe container to ON?

Sign in to comment.

Categories

Find more on App Building in Help Center and File Exchange

Asked:

on 19 Jul 2020

Edited:

on 19 Jul 2020

Community Treasure Hunt

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

Start Hunting!