📄 xiezhh2.m
字号:
function varargout = xiezhh2(varargin)
% XIEZHH2 M-file for xiezhh2.fig
% XIEZHH2, by itself, creates a new XIEZHH2 or raises the existing
% singleton*.
%
% H = XIEZHH2 returns the handle to a new XIEZHH2 or the handle to
% the existing singleton*.
%
% XIEZHH2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in XIEZHH2.M with the given input arguments.
%
% XIEZHH2('Property','Value',...) creates a new XIEZHH2 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before xiezhh2_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to xiezhh2_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 xiezhh2
% Last Modified by GUIDE v2.5 06-Sep-2006 18:07:15
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @xiezhh2_OpeningFcn, ...
'gui_OutputFcn', @xiezhh2_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 xiezhh2 is made visible.
function xiezhh2_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 xiezhh2 (see VARARGIN)
% Choose default command line output for xiezhh2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes xiezhh2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = xiezhh2_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 pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
userdata=get(gcf,'userdata');
i=length(userdata)+1;
x=get(gcbo,'value');
if x>0
userdata(i)=x;
end
set(gcf,'userdata',userdata);
pph1=findobj(gcf,'tag','popupmenu1');
udata1=get(pph1,'value');
pph2=findobj(gcf,'tag','popupmenu2');
udata2=get(pph2,'value');
edit_handle1=findobj(gcf,'tag','edit1');
n1=get(edit_handle1,'string');
n1=str2num(n1);
edit_handle2=findobj(gcf,'tag','edit2');
n2=get(edit_handle2,'string');
n2=str2num(n2);
edit_handle4=findobj(gcf,'tag','edit3');
n4=get(edit_handle4,'string');
n4=str2num(n4);
str1=strr1(udata2);
n=length(str1);
switch udata1
case 1
if ~isempty(n1)&~isempty(n2)
if n2<=0
warndlg('方差不能为负数或0');
else
n2=sqrt(n2);
x=n1-3.4*n2:6.8*n2/100:n1+3.4*n2;
y=normpdf(x,n1,n2);
if n>1
if rem(i,7)==0
plot(x,y,str1(7))
else
plot(x,y,str1(rem(i,7)))
end
else
plot(x,y,str1)
end
hold on
text(n1+0.5*n2,0.95*normpdf(n1,n1,n2),['\mu=',num2str(n1),',','\sigma=',num2str(n2)])
xlabel('X')
ylabel('f(x)')
plot(n1*ones(11,1),0:0.1*max(y):max(y),':k')
end
else
warndlg('参数不能为空');
end
case 2
if ~isempty(n1)&~isempty(n2)
if n1>=n2
warndlg('请正确输入均匀分布的参数,左端点应小于右端点');
else
x=n1-0.2*(n2-n1):(n2-n1)/100:n2+0.2*(n2-n1);
y=unifpdf(x,n1,n2);
if n>1
if rem(i,7)==0
plot(x,y,str1(7))
set(gca,'Ylim',[0 1.5/(n2-n1)])
else
plot(x,y,str1(rem(i,7)))
set(gca,'Ylim',[0 1.5/(n2-n1)])
end
else
plot(x,y,str1)
set(gca,'Ylim',[0 1.5/(n2-n1)])
end
hold on
text((n1+n2)/2,1.2/(n2-n1),['a=',num2str(n1),',','b=',num2str(n2)])
xlabel('X')
ylabel('f(x)')
end
else
warndlg('参数不能为空');
end
case 3
if ~isempty(n4)
if n4<=0
warndlg('指数分布的参数只能为正数');
else
xinv1=expinv(0.001,n4);
xinv2=expinv(0.999,n4);
x=xinv1+eps:0.01*(xinv2-xinv1):xinv2;
y=exppdf(x,n4);
if n>1
if rem(i,7)==0
plot(x,y,str1(7))
else
plot(x,y,str1(rem(i,7)))
end
else
plot(x,y,str1)
end
hold on
text(expinv(0.5,n4),exppdf(expinv(0.5,n4),n4),['\lambda=',num2str(n4)])
xlabel('X')
ylabel('f(x)')
end
else
warndlg('参数不能为空');
end
end
%set(edit_handle1,'string','')
%set(edit_handle2,'string','')
%set(edit_handle4,'string','')
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
userdata=get(gcf,'userdata');
i=length(userdata)+1;
x=get(gcbo,'value');
if x>0
userdata(i)=x;
end
set(gcf,'userdata',userdata);
pph1=findobj(gcf,'tag','popupmenu1');
udata1=get(pph1,'value');
pph2=findobj(gcf,'tag','popupmenu2');
udata2=get(pph2,'value');
edit_handle1=findobj(gcf,'tag','edit1');
n1=get(edit_handle1,'string');
n1=str2num(n1);
edit_handle2=findobj(gcf,'tag','edit2');
n2=get(edit_handle2,'string');
n2=str2num(n2);
edit_handle4=findobj(gcf,'tag','edit3');
n4=get(edit_handle4,'string');
n4=str2num(n4);
str1=strr1(udata2);
n=length(str1);
switch udata1
case 1
if ~isempty(n1)&~isempty(n2)
if n2<=0
warndlg('方差不能为负数或0');
else
n2=sqrt(n2);
x=n1-3.4*n2:6.8*n2/100:n1+3.4*n2;
y=normcdf(x,n1,n2);
if n>1
if rem(i,7)==0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -