フィルターのクリア

Abort Matlab Program via callback

3 ビュー (過去 30 日間)
Christopher
Christopher 2012 年 2 月 10 日
Hello,
I tried to abort my main matlab function via a callback function of an uicontrol function. A short example how I tried to implement it is given below. The problem is that the "error" in the callback only stops the callback function but not the main function. Is there a simple solution to solve this problem? Thanks for your help!
Example code:
function main
fh=figure;
PanicButton=uicontrol('style','pushbutton','Units','normalized',...
'string','Panic Button','BackgroundColor','r',...
'FontUnits','normalized','FontSize',.8,...
'position',[0,0,1,.2],'callback',{@Panic});
try
for ct=1:20
fprintf('%10.6f \n',ct);
pause(2)
end
catch ME
disp('Hooray! You made it!');
rethrow(ME)
end
end
function Panic(hObject,eventdata)
error('USER:Panic','User has pushed the Panic Button!');
end

採用された回答

Aurelien Queffurust
Aurelien Queffurust 2012 年 2 月 10 日
You could follow this technical solution which provides examples how to achieve this task : How can I interrupt a callback and NOT come back to finish its execution in MATLAB?

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by