Cancel Matlab execution from GUI
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Lawrence
le 31 Mar 2015
Modifié(e) : Image Analyst
le 31 Mar 2015
Hello, I'd like to create a desktop standalone application with a button which will cancel or stop the current execution. The only solution I found is throwing
error('Interrupted by user');
but it does not work when I packaged the app.
Any other suggestions? Thank you.
0 commentaires
Réponse acceptée
Image Analyst
le 31 Mar 2015
Modifié(e) : Image Analyst
le 31 Mar 2015
I use a checkbox. When the user clicks the "Go" button to start an intensive computation, I make the "Finish Now" checkbox visible and unchecked. In the code, you can check if the user has checked it, and break or exit if you find the user has checked it.
set(handles.chkFinishNow, 'Value', 0); % Uncheck it.
set(handles.chkFinishNow, 'Visible', 'on'); % Show checkbox.
for k = 1 : 100000000
% heavy code...
% Now check if the user has checked the 'Finish Now' checkbox.
if get(handles.chkFinishNow, 'Value')
% User checked it. Bail out.
break;
end
end
% Reset the checkbox.
set(handles.chkFinishNow, 'Value', 0); % Uncheck it.
set(handles.chkFinishNow, 'Visible', 'off'); % Hide it.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Application Deployment dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!