📄 ode_solver.m
字号:
% --- Executes during object creation, after setting all properties.
function edit_info_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_info (see GCBO)
% handles empty - handles not created until after all CreateFcns called
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit_info_Callback(hObject, eventdata, handles)
% hObject handle to edit_info (see GCBO)
% handles structure with handles and user data (see GUIDATA)
% --- Executes during object creation, after setting all properties.
function x_CreateFcn(hObject, eventdata, handles)
% hObject handle to x (see GCBO)
% handles empty - handles not created until after all CreateFcns called
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in x.
function x_Callback(hObject, eventdata, handles)
% hObject handle to x (see GCBO)
% handles structure with handles and user data (see GUIDATA)
set([handles.x handles.f handles.agnv handles.annv handles.init],'value',get(hObject,'Value'));
% --- Executes during object creation, after setting all properties.
function f_CreateFcn(hObject, eventdata, handles)
% hObject handle to f (see GCBO)
% handles empty - handles not created until after all CreateFcns called
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes during object creation, after setting all properties.
function agnv_CreateFcn(hObject, eventdata, handles)
% hObject handle to agnv (see GCBO)
% handles empty - handles not created until after all CreateFcns called
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes during object creation, after setting all properties.
function annv_CreateFcn(hObject, eventdata, handles)
% hObject handle to annv (see GCBO)
% handles empty - handles not created until after all CreateFcns called
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes during object creation, after setting all properties.
function init_CreateFcn(hObject, eventdata, handles)
% hObject handle to init (see GCBO)
% handles empty - handles not created until after all CreateFcns called
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on button press in add.
function add_Callback(hObject, eventdata, handles)
% hObject handle to add (see GCBO)
% handles structure with handles and user data (see GUIDATA)
N=length(get(handles.x,'string'));
x={};
for i=1:N
x{i}=['dx' num2str(i) '/dt'];
end
set(handles.x,'string',x);
prompt = {['Enter equation dx' num2str(N+1) '/dt=...'],...
'Enter additive Gaussian noise variance:',...
'Enter additve white noise variance:',...
'Enter initial condition:'};
dlg_title = 'Add new equation';
num_lines= 1;
def = {'','0','0','0.5'};
answer = inputdlg(prompt,dlg_title,num_lines,def);
if ~isempty(answer)
x=get(handles.x,'string');
f=get(handles.f,'string');
agnv=get(handles.agnv,'string');
annv=get(handles.annv,'string');
init=get(handles.init,'string');
x{N+1}=['dx' num2str(N+1) '/dt'];
f{N+1}=answer{1};
agnv{N+1}=answer{2};
annv{N+1}=answer{3};
init{N+1}=answer{4};
set([handles.x, handles.f, handles.agnv, handles.annv, handles.init],'value',N+1);
set(handles.x,'string',x);
set(handles.f,'string',f);
set(handles.agnv,'string',agnv);
set(handles.annv,'string',annv);
set(handles.init,'string',init);
end
% --- Executes on button press in modify.
function modify_Callback(hObject, eventdata, handles)
% hObject handle to modify (see GCBO)
% handles structure with handles and user data (see GUIDATA)
x=get(handles.x,'string');
f=get(handles.f,'string');
agnv=get(handles.agnv,'string');
annv=get(handles.annv,'string');
init=get(handles.init,'string');
selection=get(handles.x,'value');
if isempty(x)
x{1}='dx1/dt'; f{1}=''; agnv{1}='0'; annv{1}='0'; init{1}='0.7';
end
prompt = {['Enter equation ' x{selection} '=...'],...
'Enter additive Gaussian noise variance:',...
'Enter additve white noise variance:',...
'Enter initial condition:'};
dlg_title = 'Modify equation';
num_lines= 1;
def = {f{selection},agnv{selection},annv{selection},init{selection}};
answer = inputdlg(prompt,dlg_title,num_lines,def);
if ~isempty(answer)
f{selection}=answer{1};
agnv{selection}=answer{2};
annv{selection}=answer{3};
init{selection}=answer{4};
set(handles.x,'string',x);
set(handles.f,'string',f);
set(handles.agnv,'string',agnv);
set(handles.annv,'string',annv);
set(handles.init,'string',init);
end
% --- Executes on button press in delete.
function delete_Callback(hObject, eventdata, handles)
% hObject handle to delete (see GCBO)
% handles structure with handles and user data (see GUIDATA)
x=get(handles.x,'string');
f=get(handles.f,'string');
agnv=get(handles.agnv,'string');
annv=get(handles.annv,'string');
init=get(handles.init,'string');
selection=get(handles.x,'value');
if isempty(x)
return
end
n_f={}; n_agnv={};n_annv={}; n_init={}; n_x={};
k=1;
for i=1:length(x)
if i~=selection
n_f{k}=f{i};
n_agnv{k}=agnv{i};
n_annv{k}=annv{i};
n_init{k}=init{i};
n_x{k}=x{i};
k=k+1;
end
end
set([handles.x, handles.f, handles.agnv, handles.annv, handles.init],'value',max([1 selection-1]));
set(handles.x,'string',n_x);
set(handles.f,'string',n_f);
set(handles.agnv,'string',n_agnv);
set(handles.annv,'string',n_annv);
set(handles.init,'string',n_init);
% --- Executes during object creation, after setting all properties.
function solver_CreateFcn(hObject, eventdata, handles)
% hObject handle to solver (see GCBO)
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
set(hObject,'string',{'ode45' 'ode23' 'ode113' 'ode15s' 'ode23s' 'ode23t' 'ode23tb'});
% --- Executes on selection change in solver.
function solver_Callback(hObject, eventdata, handles)
% hObject handle to solver (see GCBO)
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns solver contents as cell array
% contents{get(hObject,'Value')} returns selected item from solver
% --- Executes during object creation, after setting all properties.
function addit_param_CreateFcn(hObject, eventdata, handles)
% hObject handle to addit_param (see GCBO)
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function addit_param_Callback(hObject, eventdata, handles)
% hObject handle to addit_param (see GCBO)
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of addit_param as text
% str2double(get(hObject,'String')) returns contents of addit_param as a double
% --- Executes during object creation, after setting all properties.
function tr_time_CreateFcn(hObject, eventdata, handles)
% hObject handle to tr_time (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function tr_time_Callback(hObject, eventdata, handles)
% hObject handle to tr_time (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of tr_time as text
% str2double(get(hObject,'String')) returns contents of tr_time as a double
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -