Button activity only works if I set a breakpoint in Matlab App Designer

1 次查看(过去 30 天)
I have the App Designer code below that should make the Button invoking the script disappear while the script runs. At completion, I have a command "app.BeginoptimizationButton.Visible="on" to make the button available again. This only works if I put a breakpoint in the script at the place indicated below, and then it works as planned. Without the breakpoint, the button remains visible though the rest of the script runs flawlessly.
I have tried using a lamp to indicate when the script is running with exactly the same problem: the lamp doesn't change without a breakpoint at the line where the command is located.
I can't figure out what to do to fix this and would greatly appreciate any advice.
Thanks,
Andy
____________________________________________
% Button pushed function: BeginoptimizationButton
function BeginoptimizationButtonPushed(app, event)
'Starting optimization'
app.MinMethod='fminsearchbnd';
app.approachinfo=['Approach: Revised Starling model using ',app.MinMethod];
app.solverinfo='solver: ode15s';
<breakpoint> app.BeginoptimizationButton.Visible="off";
t=app.t;
etc.

采纳的回答

Voss
Voss 2023-11-15
Put a drawnow after lines of code that make changes to the GUI which should take effect immediately, e.g.:
% starting optimization
app.BeginoptimizationButton.Visible="off";
drawnow
% ...
% ...
app.BeginoptimizationButton.Visible="on";
drawnow

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by