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

📄 xiezhh7.m

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

% Last Modified by GUIDE v2.5 09-Aug-2007 09:27:31

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

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = xiezhh7_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 pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

edit_handle=findobj(gcf,'tag','edit3');
vv1=get(edit_handle,'string');
value=get(gcf,'userdata');
edit_handle=findobj(gcf,'tag','edit2');

if length(value)>=2
    value=value(2:end);
    if ~isempty(vv1)
        vv1=str2num(vv1);
        if round(vv1)~=vv1|vv1<0
            warndlg('k为正整数');
        else
            kjieju=mean(value.^vv1);
            set(edit_handle,'string',num2str(kjieju));
        end
    else
        warndlg('k不能为空');
    end
else
    warndlg('请输入样本数据');
end

% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


edit_handle=findobj(gcf,'tag','edit3');
vv1=get(edit_handle,'string');
value=get(gcf,'userdata');
edit_handle=findobj(gcf,'tag','edit2');

if length(value)>=2
    value=value(2:end);
    if ~isempty(vv1)
        vv1=str2num(vv1);
        if round(vv1)~=vv1|vv1<0
            warndlg('k为正整数');
        else
            kjieju=moment(value,vv1);
            set(edit_handle,'string',num2str(kjieju));
        end
    else
        warndlg('k不能为空');
    end
else
    warndlg('请输入样本数据');
end

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



% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (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



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


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (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 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)

value=get(gcf,'userdata');
if length(value)>=2
    value=value(2:end);
    cla
    hist(value);
    xlabel('样本数据X')
    ylabel('频数')
    hold off
else
    warndlg('请输入样本数据');
end

% --- 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)

value=get(gcf,'userdata');
if length(value)>=2
    value=value(2:end);
    v1=min(value);v2=max(value);
    b=fminsearch('kernel_bmin',1,[],value);  %窗宽通过最佳拟合来求(核密度函数拟合频率直方图或拟合经验密度函数)
    %b=(v2-v1)/10;    %窗宽根据样本数据来定(样本极差/10)
    %hist_xzh1(value)   %画频率直方图
    %hold on    
    kernel_density([v1:(v2-v1)/100:v2],value,b,'epan')    %画核密度函数图
    grid on
    xlabel('样本数据X')
    ylabel('p(x)/f(x)')
    hold off
else
    warndlg('请输入样本数据');
end


% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

value=get(gcf,'userdata');
if length(value)>=2
    value=value(2:end);
    cla
    ecdf(value)
    grid on
    xlabel('样本数据X')
    ylabel('F(x)')
    hold off
else
    warndlg('请输入样本数据');
end

% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

grid off
cla

% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close 一个样本情形
yangbentj


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

edit_handle=findobj(gcf,'tag','edit1');
userdata=get(gcf,'userdata');
x=get(edit_handle,'string');
x=str2num(x);
x=x(:)';
if userdata(1)==0.01     
    if ~isempty(x)
        set(gcf,'userdata',[0,x]);        
    end           
else    
    if ~isempty(x)
        userdata=[userdata x];
        set(gcf,'userdata',userdata); 
    end       
end
set(edit_handle,'string','');


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

edit1_handle=findobj(gcf,'tag','edit1_handle');
set(edit1_handle,'string','')
set(gcf,'userdata',[0])

% 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 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)

y=get(gcf,'userdata');
y(1)=0.01;

x=y(2:end);
edit_handle=findobj(gcf,'tag','edit1');
set(edit_handle,'string',num2str(x));
set(gcf,'userdata',y);

% --- 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)

set(gcf,'userdata',[0]);
edit_handle=findobj(gcf,'tag','edit1');
set(edit_handle,'string','');



% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

value=get(gcf,'userdata');
if length(value)>=2
    value=value(2:end);
    hist_xzh1(value);
    xlabel('样本数据X')
    ylabel('p(x)/f(x)')
    hold on    
else
    warndlg('请输入样本数据');
end



% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

value=get(gcf,'userdata');
edit_handle=findobj(gcf,'tag','edit2');
if length(value)>=2
    value=value(2:end);
    fangcha=var(value);
    set(edit_handle,'string',num2str(fangcha));
else
    warndlg('请输入样本数据');
end


% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton12 (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');
edit_handle=findobj(gcf,'tag','edit1');
n=length(userdata)-1;
set(edit_handle,'string',num2str(n))
pause(2)
set(edit_handle,'string','')

⌨️ 快捷键说明

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