How use waitfor
or uiwait
in app designer of MATLAB? These funtions only work with figures (GUIDE) not app designer windows. How can I have same behavior in app designer? I'm waiting for closing second window before continuing codes of main window.
The waitfor(second_window, 'close');
is not actually waiting for the figure window to close. Specifying a second input to waitfor
tells MATLAB to block execution until the specified property changes or the object is deleted.
MATLAB autocompletes property names if there are enough characters to match a unique name*. In your case, 'close'
matches the figure's CloseRequestFcn
. UI figure objects do not have this property, hence the error.
Call waitfor
without the second input to achieve the desired behavior.
* I'm not sure if this is explicitly stated in MATLAB's documentation anywhere, but the functional equivalent is the PartialMatching
property of MATLAB's inputParser
class:
Inputs that are leading substrings of parameter names will be accepted and the value matched to that parameter. If there are multiple possible matches to the input string, MATLAB throws an error.