📄 odegui.m
字号:
function varargout = odegui(varargin)
% ODEGUI M-file for odegui.fig
% ODEGUI, by itself, creates a new ODEGUI or raises the existing
% singleton*.
%
% H = ODEGUI returns the handle to a new ODEGUI or the handle to
% the existing singleton*.
%
% ODEGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ODEGUI.M with the given input arguments.
%
% ODEGUI('Property','Value',...) creates a new ODEGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before odegui_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to odegui_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help odegui
% Last Modified by GUIDE v2.5 12-Nov-2005 11:06:51
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @odegui_OpeningFcn, ...
'gui_OutputFcn', @odegui_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before odegui is made visible.
function odegui_OpeningFcn(hObject, eventdata, handles, varargin)
set(handles.RK4SEL,'value',get(handles.RK4SEL,'max'));
set(handles.UpX,'string','1.5');
set(handles.LoX,'string','0');
set(handles.m,'string','15');
set(handles.dy,'string','-x^2*y^2');
set(handles.Iy,'string','3');
handles.T=[];
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to odegui (see VARARGIN)
% Choose default command line output for odegui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes odegui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = odegui_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in RK4SEL.
function RK4SEL_Callback(hObject, eventdata, handles)
set(handles.RK4SEL,'value',get(handles.RK4SEL,'max'));
set(handles.AB4SEL,'value',get(handles.AB4SEL,'min'));
set(handles.ABM4SEL,'value',get(handles.ABM4SEL,'min'));
set(handles.IABM4SEL,'value',get(handles.IABM4SEL,'min'));
handles.sel=1;
% hObject handle to RK4SEL (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of RK4SEL
% --- Executes on button press in AB4SEL.
function AB4SEL_Callback(hObject, eventdata, handles)
set(handles.RK4SEL,'value',get(handles.RK4SEL,'min'));
set(handles.AB4SEL,'value',get(handles.AB4SEL,'max'));
set(handles.ABM4SEL,'value',get(handles.ABM4SEL,'min'));
set(handles.IABM4SEL,'value',get(handles.IABM4SEL,'min'));
handles.sel=2;
% hObject handle to AB4SEL (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of AB4SEL
% --- Executes on button press in ABM4SEL.
function ABM4SEL_Callback(hObject, eventdata, handles)
set(handles.RK4SEL,'value',get(handles.RK4SEL,'min'));
set(handles.AB4SEL,'value',get(handles.AB4SEL,'min'));
set(handles.ABM4SEL,'value',get(handles.ABM4SEL,'max'));
set(handles.IABM4SEL,'value',get(handles.IABM4SEL,'min'));
handles.sel=3;
% hObject handle to ABM4SEL (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of ABM4SEL
% --- Executes on button press in IABM4SEL.
function IABM4SEL_Callback(hObject, eventdata, handles)
set(handles.RK4SEL,'value',get(handles.RK4SEL,'min'));
set(handles.AB4SEL,'value',get(handles.AB4SEL,'min'));
set(handles.ABM4SEL,'value',get(handles.ABM4SEL,'min'));
set(handles.IABM4SEL,'value',get(handles.IABM4SEL,'max'));
handles.sel=4;
% hObject handle to IABM4SEL (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of IABM4SEL
function dy_Callback(hObject, eventdata, handles)
dy=get(handles.dy,'string');
set(handles.dy,'string',dy);
% hObject handle to dy (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 dy as text
% str2double(get(hObject,'String')) returns contents of dy as a double
% --- Executes during object creation, after setting all properties.
function dy_CreateFcn(hObject, eventdata, handles)
% hObject handle to dy (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Iy_Callback(hObject, eventdata, handles)
Iy=get(handles.Iy,'string');
set(handles.Iy,'string',Iy);
% hObject handle to Iy (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 Iy as text
% str2double(get(hObject,'String')) returns contents of Iy as a double
% --- Executes during object creation, after setting all properties.
function Iy_CreateFcn(hObject, eventdata, handles)
% hObject handle to Iy (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function UpX_Callback(hObject, eventdata, handles)
UpX=get(handles.UpX,'string');
set(handles.UpX,'string',UpX);
% hObject handle to UpX (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 UpX as text
% str2double(get(hObject,'String')) returns contents of UpX as a double
% --- Executes during object creation, after setting all properties.
function UpX_CreateFcn(hObject, eventdata, handles)
% hObject handle to UpX (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in cal.
function cal_Callback(hObject, eventdata, handles)
dy=get(handles.dy,'string');
Iy=str2num(get(handles.Iy,'string'));
UpX=str2num(get(handles.UpX,'string'));
LoX=str2num(get(handles.LoX,'string'));
m=str2num(get(handles.m,'string'));
Index=zeros(1,4);
Index(1)=get(handles.RK4SEL,'value');
Index(2)=get(handles.AB4SEL,'value');
Index(3)=get(handles.ABM4SEL,'value');
Index(4)=get(handles.IABM4SEL,'value');
ind=find(Index==1);
switch ind
case 1
R=RK4(dy,LoX,UpX,Iy,m);
handles.T=R(:,1);
handles.Y=R(:,2);
guidata(hObject,handles);
T=handles.T;
Y=handles.Y;
title=('RK4方法');
msgbox({['X=',' ','Y=']...
,[repmat(num2str(T),1),repmat(' ',length(T)),repmat(num2str(Y),1)]},title,'help')
case 2
if ~isempty(handles.T)
T=handles.T;
Y=handles.Y;
A=AB4(dy,T',Y');
handles.Ta=A(:,1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -