MATLAB app designer button
58 次查看(过去 30 天)
显示 更早的评论
hi, in the app designer i created a 'start' button that starts the action of a long loops, and i want to create a 'stop' button that will immidietly stop the action of the first button and not waite until it finished the loops, is that possible?
0 个评论
采纳的回答
Ankit
2022-8-29
编辑:Ankit
2022-8-30
Please find attached *.zip file where you can see one example (refer below code)
properties (Access = public)
stop_sim = false;
end
methods (Access = private)
function stopSimulation(app)
app.stop_sim = true;
msgbox('simulation stopped');
end
function startSimulation(app)
i = 0;
while i<=1000000 && app.stop_sim == false
app.display.Value = num2str(i);
pause(0);
i = i + 1;
end
end
end
function StartButtonPushed(app, event)
startSimulation(app)
end
function StopButtonPushed(app, event)
stopSimulation(app)
end
Once the user pushes the StopButtonPushed button, for which the function "stopSimulation" is a callback, then the app fetch the updated properties and the condition to app.stop_sim will be set to true and hence this allows the app to terminate the while loop before reaching 1000000 iterations.
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!