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

📄 xiezhh1.m

📁 概率统计实验源程序!这是一个学习使用概率中心极限定理的工具箱
💻 M
📖 第 1 页 / 共 2 页
字号:
function varargout = xiezhh1(varargin)
% XIEZHH1 M-file for xiezhh1.fig
%      XIEZHH1, by itself, creates a new XIEZHH1 or raises the existing
%      singleton*.
%
%      H = XIEZHH1 returns the handle to a new XIEZHH1 or the handle to
%      the existing singleton*.
%
%      XIEZHH1('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in XIEZHH1.M with the given input arguments.
%
%      XIEZHH1('Property','Value',...) creates a new XIEZHH1 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before xiezhh1_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to xiezhh1_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 xiezhh1

% Last Modified by GUIDE v2.5 06-Sep-2006 15:51:20

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @xiezhh1_OpeningFcn, ...
                   'gui_OutputFcn',  @xiezhh1_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 xiezhh1 is made visible.
function xiezhh1_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 xiezhh1 (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = xiezhh1_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 pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (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','popupmenu3');
udata1=get(pph1,'value');
pph2=findobj(gcf,'tag','popupmenu4');
udata2=get(pph2,'value');
edit_handle1=findobj(gcf,'tag','edit4');
n1=get(edit_handle1,'string');
n1=str2num(n1);
edit_handle2=findobj(gcf,'tag','edit5');
n2=get(edit_handle2,'string');
n2=str2num(n2);
edit_handle4=findobj(gcf,'tag','edit6');
n4=get(edit_handle4,'string');
n4=str2num(n4);
str1=strr1(udata2);
n=length(str1);

switch udata1
    case 1
        if ~isempty(n1)&~isempty(n2)&~isempty(n4)
            if round(n1)~=n1|round(n2)~=n2|round(n4)~=n4|(n1<=0|n2<0|n4<0)|n1<n2|n1<n4
                warndlg('请正确输入超几何分布的参数');
            else
                x=hygeinv(0.001,n1,n2,n4):hygeinv(0.999,n1,n2,n4);
                y=hygepdf(x,n1,n2,n4);
                if n>1
                    if rem(i,7)==0
                        stem(x,y,'fill',str1(7))                        
                    else
                        stem(x,y,'fill',str1(rem(i,7)))                        
                    end
                else
                    stem(x,y,'fill',str1)
                end
                hold on
                x=hygeinv(0.5,n1,n2,n4);
                text(x,hygepdf(x,n1,n2,n4),['N=',num2str(n1),',','M=',num2str(n2),',','n=',num2str(n4)])
                xlabel('X')
                ylabel('P(x)')
                %plot(zeros(11,1),0:0.1*max(y):max(y),':k')
            end
        else            
            warndlg('参数不能为空');
        end
        
    case 2
        if ~isempty(n1)&~isempty(n2)
            if round(n1)~=n1|n1<0|n2<=0|n2>=1
                warndlg('请正确输入二项分布的参数');
            else                
                x=binoinv(0.001,n1,n2):binoinv(0.999,n1,n2);
                y=binopdf(x,n1,n2);
                if n>1
                    if rem(i,7)==0
                        stem(x,y,'fill',str1(7))
                    else
                        stem(x,y,'fill',str1(rem(i,7)))
                    end
                else
                    stem(x,y,'fill',str1)
                end
                hold on
                x=binoinv(0.5,n1,n2);
                text(x,binopdf(x,n1,n2),['n=',num2str(n1),',','p=',num2str(n2)])
                xlabel('X')
                ylabel('P(x)')
                %plot(zeros(11,1),0:0.1*max(y):max(y),':k')                
            end
        else
            warndlg('参数不能为空');
        end
       
    case 3
        if ~isempty(n4)
            if n4<=0
                warndlg('请正确输入泊松分布的参数');
            else               
                x=poissinv(0.001,n4):poissinv(0.999,n4);
                y=poisspdf(x,n4);
                if n>1
                    if rem(i,7)==0
                        stem(x,y,'fill',str1(7))
                    else
                        stem(x,y,'fill',str1(rem(i,7)))
                    end
                else
                    stem(x,y,'fill',str1)
                end
                hold on
                x=poissinv(0.5,n4);
                text(x,poisspdf(x,n4),['\lambda=',num2str(n4)])
                xlabel('X')
                ylabel('P(x)')
                %plot(zeros(11,1),0:0.1*max(y):max(y),':k')                
            end
        else
            warndlg('参数不能为空');
        end
      
            
end
%set(edit_handle1,'string','')
%set(edit_handle2,'string','')
%set(edit_handle4,'string','')


% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (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','popupmenu3');
udata1=get(pph1,'value');
pph2=findobj(gcf,'tag','popupmenu4');
udata2=get(pph2,'value');
edit_handle1=findobj(gcf,'tag','edit4');
n1=get(edit_handle1,'string');
n1=str2num(n1);
edit_handle2=findobj(gcf,'tag','edit5');
n2=get(edit_handle2,'string');
n2=str2num(n2);
edit_handle4=findobj(gcf,'tag','edit6');
n4=get(edit_handle4,'string');
n4=str2num(n4);
str1=strr1(udata2);
n=length(str1);

switch udata1
    case 1
        if ~isempty(n1)&~isempty(n2)&~isempty(n4)
            if round(n1)~=n1|round(n2)~=n2|round(n4)~=n4|(n1<=0|n2<0|n4<0)|n1<n2|n1<n4
                warndlg('请正确输入超几何分布的参数');
            else
                x=hygeinv(0.001,n1,n2,n4):hygeinv(0.999,n1,n2,n4);
                y=hygecdf(x,n1,n2,n4);
                m=length(x);
                if n>1                    
                    if rem(i,7)==0                        
                        hl=line([x(1:m-1);x(2:m)],[y(1:m-1);y(1:m-1)]);
                        set(hl,'color',str1(7));
                        hold on
                        stem(x,y,'fill',str1(7))
                    else
                        hl=line([x(1:m-1);x(2:m)],[y(1:m-1);y(1:m-1)]);
                        set(hl,'color',str1(rem(i,7)));
                        hold on
                        stem(x,y,'fill',str1(rem(i,7)))
                    end
                else

⌨️ 快捷键说明

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