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

📄 feicanshujianyan.m

📁 实现在MATLAB环境下的非参数估计实验的傻瓜式操作
💻 M
字号:
function varargout = feicanshujianyan(varargin)%FEICANSHUJIANYAN M-file for feicanshujianyan.fig%      FEICANSHUJIANYAN, by itself, creates a new FEICANSHUJIANYAN or raises the existing%      singleton*.%%      H = FEICANSHUJIANYAN returns the handle to a new FEICANSHUJIANYAN or the handle to%      the existing singleton*.%%      FEICANSHUJIANYAN('Property','Value',...) creates a new FEICANSHUJIANYAN using the%      given property value pairs. Unrecognized properties are passed via%      varargin to feicanshujianyan_OpeningFcn.  This calling syntax produces a%      warning when there is an existing singleton*.%%      FEICANSHUJIANYAN('CALLBACK') and FEICANSHUJIANYAN('CALLBACK',hObject,...) call the%      local function named CALLBACK in FEICANSHUJIANYAN.M with the given input%      arguments.%%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one%      instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help feicanshujianyan% Last Modified by GUIDE v2.5 12-Sep-2007 15:58:30% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...                   'gui_Singleton',  gui_Singleton, ...                   'gui_OpeningFcn', @feicanshujianyan_OpeningFcn, ...                   'gui_OutputFcn',  @feicanshujianyan_OutputFcn, ...                   'gui_LayoutFcn',  [], ...                   'gui_Callback',   []);if nargin && ischar(varargin{1})   gui_State.gui_Callback = str2func(varargin{1});endif 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 feicanshujianyan is made visible.function feicanshujianyan_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   unrecognized PropertyName/PropertyValue pairs from the%            command line (see VARARGIN)% Choose default command line output for feicanshujianyanhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes feicanshujianyan wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = feicanshujianyan_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 structurevarargout{1} = handles.output;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% --- 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)set(handles.edit1,'string','');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');endfunction 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');endfunction 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');endfunction edit5_Callback(hObject, eventdata, handles)% hObject    handle to edit5 (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 edit5 as text%        str2double(get(hObject,'String')) returns contents of edit5 as a double% --- Executes during object creation, after setting all properties.function edit5_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit5 (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 popupmenu1.function popupmenu1_Callback(hObject, eventdata, handles)% hObject    handle to popupmenu1 (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 popupmenu1 contents as cell array%        contents{get(hObject,'Value')} returns selected item from popupmenu1set(handles.uipanel1,'visible','on');set(handles.edit2,'string','');set(handles.edit3,'string','');popup_sel_index = get(handles.popupmenu1, 'Value');switch popup_sel_index    case 1        set(handles.uipanel1,'visible','off');    case 2        set(handles.edit2,'string','');         set(handles.text4, 'String', '输入k的值');         set(handles.text2, 'String', '输入两行多列的矩阵');        k=str2num(get(handles.edit3,'string'))    ;        set(handles.edit3,'visible','on');        set(handles.text4,'visible','on');        set(handles.text4,'visible','on');        set(handles.text5,'string','输出xx0的值')        set(handles.text6,'string','输出xx的值')        set(handles.text9,'string','进行卡方检验')    case 3            set(handles.edit2,'string','');        set(handles.text2, 'String', '输入多行多列的矩阵');        set(handles.edit3,'visible','off');        set(handles.text4,'visible','off');        set(handles.text5,'string','输出xx0的值')        set(handles.text6,'string','输出xx的值')        set(handles.text9,'string','进行卡方检验')    case 4        set(handles.edit2,'string','');        set(handles.text2, 'String', '输入两行多列的矩阵');        set(handles.edit3,'visible','off');        set(handles.text4,'visible','off');        set(handles.text5,'string','输出t0的值')        set(handles.text6,'string','输出t的值')        set(handles.text9,'string','进行T检验')    case 5        set(handles.edit2,'string','');        set(handles.text2, 'String', '输入一行多列的向量');         set(handles.text4, 'String', '输入n1的值');        n1=str2num(get(handles.edit3,'string'))    ;        set(handles.edit3,'visible','on');        set(handles.edit5,'visible','on');        set(handles.text4,'visible','on');        set(handles.text5,'string','输出t0的值')        set(handles.text6,'string','输出t的值')        set(handles.text9,'string','进行T检验')end% --- Executes during object creation, after setting all properties.function popupmenu1_CreateFcn(hObject, eventdata, handles)% hObject    handle to popupmenu1 (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 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)% --- 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(handles.uipanel1,'visible','off');set(handles.uipanel2,'visible','on');A=str2num(get(handles.edit1,'string'));p=str2num(get(handles.edit2,'string'));popup_sel_index = get(handles.popupmenu1, 'Value');switch popup_sel_index    case 2  %进行分析假设检验和符合性检验[m l]=size(A);n=0;for i=1:l    n=n+A(1,i);endxx0=0;for i=1:l        xx0=xx0+(A(1,i)-n*A(2,i))^2/n/A(2,i);endk=str2num(get(handles.edit3,'string'));v=l-k-1;%求出自由度xx=chi2inv(1-p,v);if xx0>xx   %判断是否接受H0    msgbox('拒绝H0')else    msgbox('接受H0')endif n==0    msgbox('请输入数据','waring');endset(handles.edit4,'string',num2str(xx0))set(handles.edit5,'string',num2str(xx))set(handles.text5,'string','输出xx0的值')        set(handles.text6,'string','输出xx的值')        set(handles.text9,'string','进行卡方检验')    case 3   %进行独立性检验[m n]=size(A);for i=1:m  R(i,1)=0;  for j=1:n      R(i,1)=R(i,1)+A(i,j);  end  R(i,1);endfor i=1:n    C(1,i)=0;    for j=1:m        C(1,i)=C(1,i)+A(j,i);    end    C(1,i);endxx0=0;for i=1:m    for j=1:n        xx0=xx0+A(i,j)^2/(R(i)*C(j));    endendN=0;for  i=1:m    N=N+R(i,1);endxx0=N*(xx0-1);v=(m-1)*(n-1);%求出自由度xx=chi2inv(1-p,v);if xx0>xx  %判断是否接受H0    msgbox('拒绝H0');else    msgbox('接受H0');endif n==0    msgbox('请输入数据','waring');endset(handles.edit4,'string',num2str(xx0))set(handles.edit5,'string',num2str(xx))    case 4   %进行符号检验[m n]=size(A);%求出向量X的大小N1=0;N2=0;for i=1:n    f(i)=A(1,i)-A(2,i);    if  f(i)>0        N1=N1+1;    elseif f(i)<0        N2=N2+1;    endendif N1==0    msgbox('请输入数据','waring');endN=N1+N2;if N<5    msgbox('请重新输入X与Y的值');else    p1=0.5;q=0.5;    t0 =abs((abs(N1-N*p1)-0.5)/sqrt(N*p1*q));endt=tinv(1-p,N-1);if t0>t   %判断是否接受H0    msgbox('拒绝H0')else    msgbox('接受H0')endset(handles.edit4,'string',num2str(t0))set(handles.edit5,'string',num2str(t))    case 5   %进行中位数检验  n1=str2num(get(handles.edit3,'string'));        set(handles.text4, 'String', '输入第一个数组x的个数n1');zh=nanmedian(A);[m n]=size(A);if n==0    msgbox('请输入数据','waring');endn1=str2num(get(handles.edit3,'string'));m1=0;for i=1:n1    if  A(1,i)>zh        m1=m1+1;    endendm2=0;for i=n1+1:n    if A(1,i)>zh        m2=m2+1;    endendp1=1/2;q=1/2;t0=abs(abs(m1/n1-m2/(n-n1))/sqrt(p1*q*(1/n1+1/(n-n1))));%T检验中T的值t=tinv(1-p,n-2);if t0>t    %判断是否接受H0    msgbox('拒绝H0')else    msgbox('接受H0')endset(handles.edit4,'string',num2str(t0))set(handles.edit5,'string',num2str(t))  end% --- Executes on key press over popupmenu1 with no controls selected.function popupmenu1_KeyPressFcn(hObject, eventdata, handles)% hObject    handle to popupmenu1 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- If Enable == 'on', executes on mouse press in 5 pixel border.% --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu1.function popupmenu1_ButtonDownFcn(hObject, eventdata, handles)% hObject    handle to popupmenu1 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)

⌨️ 快捷键说明

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