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

📄 xiezhh.m

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

% Last Modified by GUIDE v2.5 02-Sep-2006 13:28:04

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

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = xiezhh_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','popupmenu2');
udata1=get(pph1,'value');
pph2=findobj(gcf,'tag','popupmenu3');
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','edit4');
n4=get(edit_handle4,'string');
n4=str2num(n4);
str1=strr1(udata2);
n=length(str1);

switch udata1
    case 4
        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 1
        if ~isempty(n4)
            if (round(n4)~=n4)|n4<=0
                warndlg('自由度只能为正整数');
            else
                xinv1=chi2inv(0.00001,n4);
                xinv2=chi2inv(0.999,n4);
                x=xinv1:0.01*(xinv2-xinv1):xinv2;
                y=chi2pdf(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(0.8*xinv2,chi2pdf(0.8*xinv2,n4),['n=',num2str(n4)])
                xlabel('X')
                ylabel('f(x)')                              
            end
        else
            warndlg('参数不能为空');
        end
       
    case 2
        if ~isempty(n4)
            if (round(n4)~=n4)|n4<=0
                warndlg('自由度只能为正整数');
            else
                xinv1=tinv(0.001,n4);
                xinv2=tinv(0.999,n4);
                x=xinv1:0.01*(xinv2-xinv1):xinv2;
                y=tpdf(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(0.5,0.95*tpdf(0,n4),['n=',num2str(n4)])
                xlabel('X')
                ylabel('f(x)')
                plot(zeros(11,1),0:0.1*max(y):max(y),':k')                
            end
        else
            warndlg('参数不能为空');
        end
        
        
    case 3
        if ~isempty(n1)&~isempty(n2)
            if (round(n1)~=n1|round(n2)~=n2)|(n1<=0|n2<=0)
               warndlg('自由度只能为正整数');
            else
                xinv1=finv(0.00001,n1,n2);
                xinv2=finv(0.99,n1,n2);
                x=xinv1:0.01*(xinv2-xinv1):xinv2;
                y=fpdf(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(finv(0.5,n1,n2),fpdf(finv(0.5,n1,n2),n1,n2),['n_1=',num2str(n1),',','n_2=',num2str(n2)])
                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','popupmenu2');
udata1=get(pph1,'value');
pph2=findobj(gcf,'tag','popupmenu3');
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','edit4');
n4=get(edit_handle4,'string');
n4=str2num(n4);
str1=strr1(udata2);
n=length(str1);

switch udata1
    case 4
        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 + -