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

📄 szjf.m

📁 matlab实现四种积分方法的比较代!!!
💻 M
字号:
function varargout = szjf(varargin)
% SZJF M-file for szjf.fig
%      SZJF, by itself, creates a new SZJF or raises the existing
%      singleton*.
%
%      H = SZJF returns the handle to a new SZJF or the handle to
%      the existing singleton*.
%
%      SZJF('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in SZJF.M with the given input arguments.
%
%      SZJF('Property','Value',...) creates a new SZJF or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before szjf_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to szjf_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 szjf

% Last Modified by GUIDE v2.5 17-Nov-2008 13:35:48

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @szjf_OpeningFcn, ...
                   'gui_OutputFcn',  @szjf_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 szjf is made visible.
function szjf_OpeningFcn(hObject, eventdata, handles, varargin)
% 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 szjf (see VARARGIN)

%Create default data










% Choose default command line output for szjf
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);


% UIWAIT makes szjf wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = szjf_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 jxBtn.
function jxBtn_Callback(hObject, eventdata, handles)
% hObject    handle to jxBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
n=handles.jf.n;
x=linspace(0,pi/2);
s=0;
for i=2:n
    s=s+sin((pi/((n-1)*2))*i);
end
 S1=(pi/(2*(n-1)))*s;
 set(handles.txtjx,'String',S1)


% --- Executes on button press in xpsBtn.
function xpsBtn_Callback(hObject, eventdata, handles)
% hObject    handle to xpsBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
n=handles.jf.n;
s1=0;
s2=0;
for i=1:(n-1)
    s1=s1+(4/6)*sin((pi/(2*(n-1)))*((2*i-1)/2));
    s2=s2+((1/6)*sin((pi/(2*(n-1)))*i))*2;
end
S3=(pi/(2*(n-1)))*(s1+s2+1/6);
 set(handles.txtxps,'String',S3)


% --- Executes on button press in nhBtn.
function nhBtn_Callback(hObject, eventdata, handles)
% hObject    handle to nhBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
n=handles.jf.n;
s1=0;
s2=0;
s3=0;
for i=1:(n-1)
    s1=s1+(3/8)*sin((pi/(2*(n-1)))*((3*i-2)/3));
    s2=s2+(3/8)*sin((pi/(2*(n-1)))*((3*i-1)/3));
    s3=s3+((1/8)*sin((pi/(2*(n-1)))*i))*2;
end
S4=(pi/(2*(n-1)))*(s1+s2+s3+1/8);
 set(handles.txtnh,'String',S4)

% --- Executes on button press in txBtn.
function txBtn_Callback(hObject, eventdata, handles)
% hObject    handle to txBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
n=handles.jf.n;
s=0;
for i=2:(n-1)
    s=s+sin((pi/(2*(n-1)))*i);
end
S2=(pi/(2*(n-1)))*(s+1/2);
 set(handles.txttx,'String',S2)

function txtjx_Callback(hObject, eventdata, handles)
% hObject    handle to txtjx (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 txtjx as text
%        str2double(get(hObject,'String')) returns contents of txtjx as a double



% --- Executes during object creation, after setting all properties.
function txtjx_CreateFcn(hObject, eventdata, handles)
% hObject    handle to txtjx (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 txttx_Callback(hObject, eventdata, handles)
% hObject    handle to txttx (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 txttx as text
%        str2double(get(hObject,'String')) returns contents of txttx as a double

% --- Executes during object creation, after setting all properties.
function txttx_CreateFcn(hObject, eventdata, handles)
% hObject    handle to txttx (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 txtxps_Callback(hObject, eventdata, handles)
% hObject    handle to txtxps (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 txtxps as text
%        str2double(get(hObject,'String')) returns contents of txtxps as a double


% --- Executes during object creation, after setting all properties.
function txtxps_CreateFcn(hObject, eventdata, handles)
% hObject    handle to txtxps (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 txtnh_Callback(hObject, eventdata, handles)
% hObject    handle to txtnh (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 txtnh as text
%        str2double(get(hObject,'String')) returns contents of txtnh as a double


% --- Executes during object creation, after setting all properties.
function txtnh_CreateFcn(hObject, eventdata, handles)
% hObject    handle to txtnh (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 txtn_Callback(hObject, eventdata, handles)
% hObject    handle to txtn (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 txtn as text
%        str2double(get(hObject,'String')) returns contents of txtn as a double
n=str2double(get(hObject,'String'));
if isnan(n)
    set(hObject, 'String', 0);
    errordlg('Input must be a number','Error');
end

handles.jf.n = n;
guidata(hObject,handles)

% --- Executes during object creation, after setting all properties.
function txtn_CreateFcn(hObject, eventdata, handles)
% hObject    handle to txtn (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 open_Callback(hObject, eventdata, handles)
% hObject    handle to open (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
file = uigetfile('*.fig');
if ~isequal(file, 0)
    open(file);
end

% --------------------------------------------------------------------
function print_Callback(hObject, eventdata, handles)
% hObject    handle to print (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

printdlg(handles.figure1)
% --------------------------------------------------------------------
function close_Callback(hObject, eventdata, handles)
% hObject    handle to close (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

selection = questdlg(['Close ' get(handles.figure1,'Name') '?'],...
                     ['Close ' get(handles.figure1,'Name') '...'],...
                     'Yes','No','Yes');
if strcmp(selection,'No')
    return;
end

delete(handles.figure1)

⌨️ 快捷键说明

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