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

📄 xiezhh.m

📁 概率统计实验源程序!这是一个学习使用概率中心极限定理的工具箱
💻 M
📖 第 1 页 / 共 2 页
字号:
                        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')  
                h=refline(0,0.5);
                set(h,'color',[0,0,0],'LineStyle',':')
            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=chi2cdf(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)')
                plot(chi2inv(0.5,n4)*ones(11,1),0:0.1*max(y):max(y),':k')
                h=refline(0,0.5);
                set(h,'color',[0,0,0],'LineStyle',':')
            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=tcdf(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(tinv(0.5,n4)*ones(11,1),0:0.1*max(y):max(y),':k')   
                h=refline(0,0.5);
                set(h,'color',[0,0,0],'LineStyle',':')
            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=fcdf(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)')
                plot(finv(0.5,n1,n2)*ones(11,1),0:0.1*max(y):max(y),':k')  
                h=refline(0,0.5);
                set(h,'color',[0,0,0],'LineStyle',':')
            end
        else
            warndlg('参数不能为空');
        end
        
end
%set(edit_handle1,'string','')
%set(edit_handle2,'string','')
%set(edit_handle4,'string','')

% --- 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_handle1=findobj(gcf,'tag','edit1');
%edit_handle2=findobj(gcf,'tag','edit2');
%edit_handle4=findobj(gcf,'tag','edit4');
%set(edit_handle1,'string','')
%set(edit_handle2,'string','')
%set(edit_handle4,'string','')

cla

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


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

% 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

edit_handle=findobj(gcf,'tag','edit1');
set(edit_handle,'string','');
edit2_handle=findobj(gcf,'tag','edit2');
set(edit2_handle,'string','');
edit3_handle=findobj(gcf,'tag','edit4');
set(edit3_handle,'string','');
pph=findobj(gcf,'tag','popupmenu2');
set(pph,'string','卡方分布|t分布|F分布|正态分布','FontSize',10)
pph=findobj(gcf,'tag','popupmenu3');
set(pph,'string','自动|蓝色|红色|黄色|绿色|品红|青色|黑色','FontSize',10)

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


% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu2


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

% Hint: popupmenu 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 selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu3


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

% Hint: popupmenu 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 edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (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 edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (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 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)
close 卡方、t、F分布
shiyan

⌨️ 快捷键说明

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