📄 qjgj2.m
字号:
function varargout = QJgj2(varargin)%QJGJ2 M-file for QJgj2.fig% QJGJ2, by itself, creates a new QJGJ2 or raises the existing% singleton*.%% H = QJGJ2 returns the handle to a new QJGJ2 or the handle to% the existing singleton*.%% QJGJ2('Property','Value',...) creates a new QJGJ2 using the% given property value pairs. Unrecognized properties are passed via% varargin to QJgj2_OpeningFcn. This calling syntax produces a% warning when there is an existing singleton*.%% QJGJ2('CALLBACK') and QJGJ2('CALLBACK',hObject,...) call the% local function named CALLBACK in QJGJ2.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 QJgj2% Last Modified by GUIDE v2.5 08-Aug-2007 11:33:23% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @QJgj2_OpeningFcn, ... 'gui_OutputFcn', @QJgj2_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 QJgj2 is made visible.function QJgj2_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 QJgj2handles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes QJgj2 wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = QJgj2_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;% --- 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)set(handles.edit3,'String',num2str(sh)); %输出置信区间的上限set(handles.edit2,'String',num2str(xi)); %输出置信区间的下限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');endfunction 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');end% --- Executes on button press in checkbox7.function checkbox1_Callback(hObject, eventdata, handles)% hObject handle to checkbox7 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of checkbox7% --- Executes on button press in checkbox8.function checkbox2_Callback(hObject, eventdata, handles)% hObject handle to checkbox8 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of checkbox8% --- Executes on button press in checkbox10.function checkbox3_Callback(hObject, eventdata, handles)% hObject handle to checkbox10 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of checkbox10function 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 radiobutton2.function radiobutton2_Callback(hObject, eventdata, handles)% hObject handle to radiobutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of radiobutton2% --- Executes on button press in radiobutton3.function radiobutton3_Callback(hObject, eventdata, handles)% hObject handle to radiobutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of radiobutton3% --------------------------------------------------------------------function uipanel2_SelectionChangeFcn(hObject, eventdata, handles)% hObject handle to uipanel2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)a=str2num(get(handles.edit1,'string'));b=str2num(get(handles.edit4,'string'));aj=mean(a); %得到样本均值bj=mean(b);Sa=var(a); %得到样本方差Sb=var(b);n1=length(a); %得到样本容量n2=length(b);alpha=0.05; %给定常数alphau2a=norminv(2*alpha,0,1); %给定alpha,得到标准正态分布的双侧分位数Sy=sqrt(Sa/n1+Sb/n2); %Sy为样本均值差的标注差S=sqrt(((n1-1)*Sa+(n2-1)*Sb)/(n1+n2-2));t2a=tinv(2*alpha,n1+n2-2); %给定alpha,得到t分布的双侧分位数if (hObject == handles.radiobutton2) sigma=0.2; sigma1=0.1; sigma2=0.4; if sigma~=NaN %判断sigma是否已知 f0=0; else f0=1; end if sigma1~=NaN %判断sigma1是否已知 f1=0; else f1=1; end if sigma2~=NaN %判断sigma2是否已知 f2=0; else f2=1; end if f1==0 & f2==0 %当sigma1及sigma2为已知时 Sz=sqrt(sigma1^2/n1+sigma2^2/n2); %Sz为总体均值差的标注差 sh=aj-bj+u2a*Sz; xi=aj-bj-u2a*Sz; elseif f1==1 & f2==1 & n1>=50 & n2>=50 %当igma1与sigma2均为未知且n1与n2均不小于50时 sh=aj-bj+u2a*Sy; xi=aj-bj-u2a*Sy; else sigma1==sigma2 & sigma1==sigma & f0==1 & f1==1 & f2==1 %当sigma1与sigma2均为未知,且sigma1^2=sigma2^2=sigma^2时 sh=a1-b1+t2a*S*sqrt(1/n1+1/n2); xi=a1-b1-t2a*S*sqrt(1/n1+1/n2); endelse mu1=6; mu2=7; if mu1~=NaN %判断mu1是否已知 f3=0; else f3=1; end if mu2~=NaN %判断mu2是否已知 f4=0; else f4=1; end F=finv(alpha/2,n2-1,n1-1); %给定alpha,得到f分布的双侧分位数 while f3==1 & f4==1 sh=F*Sa/Sb; xi=Sa/Sb*F; endend% --- 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 popupmenu1% --- 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -