⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dblquadgui.m

📁 数值分析程序中的一个例子
💻 M
字号:
function varargout = dblquadGUI(varargin)%DBLQUADGUI M-file for dblquadGUI.fig%      DBLQUADGUI, by itself, creates a new DBLQUADGUI or raises the existing%      singleton*.%%      H = DBLQUADGUI returns the handle to a new DBLQUADGUI or the handle to%      the existing singleton*.%%      DBLQUADGUI('Property','Value',...) creates a new DBLQUADGUI using the%      given property value pairs. Unrecognized properties are passed via%      varargin to dblquadGUI_OpeningFcn.  This calling syntax produces a%      warning when there is an existing singleton*.%%      DBLQUADGUI('CALLBACK') and DBLQUADGUI('CALLBACK',hObject,...) call the%      local function named CALLBACK in DBLQUADGUI.M with the given input%      arguments.%%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one%      instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help dblquadGUI% Last Modified by GUIDE v2.5 06-Nov-2005 16:34:55% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...                   'gui_Singleton',  gui_Singleton, ...                   'gui_OpeningFcn', @dblquadGUI_OpeningFcn, ...                   'gui_OutputFcn',  @dblquadGUI_OutputFcn, ...                   'gui_LayoutFcn',  [], ...                   'gui_Callback',   []);if nargin && ischar(varargin{1})   gui_State.gui_Callback = str2func(varargin{1});endif 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 dblquadGUI is made visible.function dblquadGUI_OpeningFcn(hObject, eventdata, handles, varargin)set(handles.fcn,'string','tan(x.^2+y.^2)');set(handles.a,'string','0');set(handles.b,'string','pi/3');set(handles.c,'string','0');set(handles.d,'string','pi/6');set(handles.eps,'string','0.5*1e-9');% 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   unrecognized PropertyName/PropertyValue pairs from the%            command line (see VARARGIN)% Choose default command line output for dblquadGUIhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes dblquadGUI wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = dblquadGUI_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 structurevarargout{1} = handles.output;function fcn_Callback(hObject, eventdata, handles)fcn=get(handles.fcn,'string');set(handles.fcn,'string',fcn);% hObject    handle to fcn (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 fcn as text%        str2double(get(hObject,'String')) returns contents of fcn as a double% --- Executes during object creation, after setting all properties.function fcn_CreateFcn(hObject, eventdata, handles)% hObject    handle to fcn (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');endfunction INV_fcn_Callback(hObject, eventdata, handles)% hObject    handle to INV_fcn (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 INV_fcn as text%        str2double(get(hObject,'String')) returns contents of INV_fcn as a double% --- Executes during object creation, after setting all properties.function INV_fcn_CreateFcn(hObject, eventdata, handles)% hObject    handle to INV_fcn (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)format longfcn=get(handles.fcn,'string');a=str2num(get(handles.a,'string'));b=str2num(get(handles.b,'string'));c=str2num(get(handles.c,'string'));d=str2num(get(handles.d,'string'));eps=str2num(get(handles.eps,'string'));tic;I=dblquad(fcn,a,b,c,d,'quad8');toc;handles.I=I;set(handles.INV_fcn,'string',num2str(I,10));set(handles.CT,'string',num2str(toc));guidata(hObject,handles);% hObject    handle to Cal (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes during object creation, after setting all properties.function a_CreateFcn(hObject, eventdata, handles)% hObject    handle to a (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');endfunction c_Callback(hObject, eventdata, handles) c= get(gcbo,'String'); set(handles.c,'string',c); % hObject    handle to c (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 c as text%        str2double(get(hObject,'String')) returns contents of c as a double% --- Executes during object creation, after setting all properties.function c_CreateFcn(hObject, eventdata, handles)% hObject    handle to c (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 during object creation, after setting all properties.function b_CreateFcn(hObject, eventdata, handles)% hObject    handle to b (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 during object creation, after setting all properties.function d_CreateFcn(hObject, eventdata, handles)% hObject    handle to d (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 during object creation, after setting all properties.function CT_CreateFcn(hObject, eventdata, handles)% hObject    handle to CT (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 Closef.function Closef_Callback(hObject, eventdata, handles)close;% hObject    handle to Closef (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)function [I2 i]=MultipleIntegral(fcn,a,b,c,d,m0,n0,eps);i=0;I1=0;I2=0;fxy=inline(fcn,'x','y');while(i==0|abs(I2-I1)>eps)    m=m0*2^i;    n=n0*2^i;    h=(b-a)/m;    k=(d-c)/n;    x=a:h:b;    y=c:k:d;    X=zeros(m,1);    Y=zeros(n,1);    for p=1:m        X(p,1)=(x(p)+x(p+1))/2;    end    for q=1:n        Y(q,1)=(y(q)+y(q+1))/2;    end     S=zeros(m,n);    for p=1:m        for q=1:n             S(p,q)=h*k/4*(fxy(x(p),y(q))+fxy(x(p),y(q+1))...             +fxy(x(p+1),y(q))+fxy(x(p+1),y(q+1)));        end    end    TMN=sum(sum(S));    S=zeros(m,1);    for p=1:m        S(p,1)=fxy(X(p,1),y(1))+fxy(X(p,1),y(n+1));    end    T2MN=1/4*TMN+h*k/8*sum(sum(S));    S=zeros(n,1);    for q=1:n         S(q,1)=fxy(x(1),Y(q,1))+fxy(x(m+1),Y(q,1));    end    T2MN=T2MN++h*k/8*sum(sum(S));    S=zeros(m,n-1);    for p=1:m        for q=2:n            S(p,q-1)=fxy(X(p),y(q));        end    end    T2MN=T2MN+h*k/4*sum(sum(S));     S=zeros(m-1,n);    for p=2:m        for q=1:n            S(p-1,q)=fxy(x(p),Y(q));        end    end    T2MN=T2MN+h*k/4*sum(sum(S));    S=zeros(m,n);    for p=1:m        for q=1:n            S(p,q)=fxy(X(p),Y(q));        end    end    T2MN=T2MN+h*k/4*sum(sum(S));    i=i+1;    I1=I2;    I2=4/3*T2MN-TMN/3;    clear x y X Y S;end function a_Callback(hObject, eventdata, handles) a= get(gcbo,'String'); set(handles.a,'string',a); % hObject    handle to a (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 a as text%        str2double(get(hObject,'String')) returns contents of a as a doublefunction b_Callback(hObject, eventdata, handles) b= get(gcbo,'String'); set(handles.b,'string',b); % hObject    handle to b (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 b as text%        str2double(get(hObject,'String')) returns contents of b as a doublefunction d_Callback(hObject, eventdata, handles) d= get(gcbo,'String'); set(handles.d,'string',d); % hObject    handle to d (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 d as text%        str2double(get(hObject,'String')) returns contents of d as a doublefunction eps_Callback(hObject, eventdata, handles) eps= get(gcbo,'String'); set(handles.eps,'string',eps); % hObject    handle to eps (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 eps as text%        str2double(get(hObject,'String')) returns contents of eps as a double% --- Executes during object creation, after setting all properties.function eps_CreateFcn(hObject, eventdata, handles)% hObject    handle to eps (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');endfunction CT_Callback(hObject, eventdata, handles)% hObject    handle to CT (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 CT as text%        str2double(get(hObject,'String')) returns contents of CT as a double

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -