📄 sde_solver.m
字号:
end
catch
errordlg('Wrong file format','File error');
end
end
% --- Executes on button press in save.
function save_Callback(hObject, eventdata, handles)
% hObject handle to save (see GCBO)
% handles structure with handles and user data (see GUIDATA)
[file,path] = uiputfile('*.mat','Save System As');
if file~=0
sde.dx=get(handles.x,'string');
sde.f=get(handles.f,'string');
sde.g=get(handles.g,'string');
sde.agnv=get(handles.agnv,'string');
sde.annv=get(handles.annv,'string');
sde.init=get(handles.init,'string');
sde.info=get(handles.edit_info,'string');
sde.time=get(handles.edit_length,'string');
str=get(handles.solver,'string');
sde.solver=str{get(handles.solver,'value')};
save([path file],'sde');
end
% --- 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.g 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 g_CreateFcn(hObject, eventdata, handles)
% hObject handle to g (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)];
end
set(handles.x,'string',x);
prompt={'Enter f:',...
'Enter g:',...
'Enter additive Gaussian noise variance:',...
'Enter additve white noise variance:',...
'Enter initial condition:'};
dlg_title = ['Enter equation for dx' num2str(N+1) ' (f and g parts)'];
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');
g=get(handles.g,'string');
agnv=get(handles.agnv,'string');
annv=get(handles.annv,'string');
init=get(handles.init,'string');
x{N+1}=['dx' num2str(N+1)];
f{N+1}=answer{1};
g{N+1}=answer{2};
agnv{N+1}=answer{3};
annv{N+1}=answer{4};
init{N+1}=answer{5};
set([handles.x, handles.f, handles.g, handles.agnv, handles.annv, handles.init],'value',N+1);
set(handles.x,'string',x);
set(handles.f,'string',f);
set(handles.g,'string',g);
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');
g=get(handles.g,'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'; f{1}=''; g{1}=''; agnv{1}='0'; annv{1}='0'; init{1}='0.5';
end
prompt={'Enter f:',...
'Enter g:',...
'Enter additive Gaussian noise variance:',...
'Enter additve white noise variance:',...
'Enter initial condition:'};
dlg_title = ['Modify equation for ' x{selection}];
num_lines= 1;
def = {f{selection},g{selection},agnv{selection},annv{selection},init{selection}};
answer = inputdlg(prompt,dlg_title,num_lines,def);
if ~isempty(answer)
f{selection}=answer{1};
g{selection}=answer{2};
agnv{selection}=answer{3};
annv{selection}=answer{4};
init{selection}=answer{5};
set(handles.x,'string',x);
set(handles.f,'string',f);
set(handles.g,'string',g);
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');
g=get(handles.g,'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_g={}; n_agnv={};n_annv={}; n_init={}; n_x={};
k=1;
for i=1:length(x)
if i~=selection
n_f{k}=f{i};
n_g{k}=g{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.g, 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.g,'string',n_g);
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',{'Milstein (Ito SDE)'});
% --- 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -