GUI stop button for ode45
古いコメントを表示
I am making a GUI where I am solving a system of ODE's using ode45, and I whish to have a stop button in my GUI. I have tried the following, without success. The value of handles.Flag is changed when I push the button, but the outputfunction doesn't seem to notice. Any suggestions?
The function where I call ode45 is given under:
function Start_Callback(hObject, eventdata, handles)
% hObject handle to Start (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.Flag = false;
....
opts=odeset;
opts=odeset(opts,'RelTol',1e-6,'AbsTol',1e-9,'Stats','on','OutputFcn',...
@odeOut);
ode45(@odefun4,tspan,T2,opts);
Where odeOut is:
handles = guidata(gcbo);
...
if handles.Flag
status=true;
else
status = false;
end
guidata(gcbo, handles);
And the stop button function is:
function Stop_Callback(hObject, eventdata, handles)
% hObject handle to Stop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.Flag = true;
% save the changes to the structure
guidata(hObject,handles)
[EDITED, Jan Simon, code formatted]
回答 (1 件)
Jan
2012 年 3 月 2 日
0 投票
You define "status" in the OutputFcn. But what happens with this value? Did you try to set a breakpoint in the "status=false" line to see what happens?
I do not find a description of the flag replied by the OutputFcn in the documentation. I do not expect, that it is sufficient for stopping the integration. But the Event function has a flag, which can be used for this reason.
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!