?? qjgj.m
字號:
function varargout = QJGJ(varargin)
% QJGJ M-file for QJGJ.fig
% QJGJ, by itself, creates a new QJGJ or raises the existing
% singleton*.
%
% H = QJGJ returns the handle to a new QJGJ or the handle to
% the existing singleton*.
%
% QJGJ('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in QJGJ.M with the given input arguments.
%
% QJGJ('Property','Value',...) creates a new QJGJ or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before QJGJ_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to QJGJ_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 QJGJ
% Last Modified by GUIDE v2.5 11-Aug-2007 10:34:13
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @QJGJ_OpeningFcn, ...
'gui_OutputFcn', @QJGJ_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 QJGJ is made visible.
function QJGJ_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 QJGJ (see VARARGIN)
% Choose default command line output for QJGJ
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes QJGJ wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = QJGJ_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 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
% --- 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)
popup_sel_index = get(handles.popupmenu1, 'Value');
switch popup_sel_index
case 1
a=str2num(get(handles.edit1,'string')); %得到用戶輸入的數據
alpha=str2num(get(handles.edit5,'string'));
[MUHAT,SIGMAHAT,MUCI,SIGMACI]=normfit(a,alpha); %此函數對于參數mu和sigma分別在二者一個
%為待估參數和另一個為多余參數時均適用
%且多余參數已知或未知均可
[m1 n1]=size(MUCI); %觀察MUCI的維數
sh1=MUCI(1,1); %得到置信區間的上限
xi1=MUCI(2,1); %得到置信區間的下限
sh2=SIGMACI(1,1);
xi2=SIGMACI(2,1);
set(handles.edit3,'String',num2str(sh1)); %輸出置信區間的上限
set(handles.edit4,'String',num2str(xi1)); %輸出置信區間的下限
set(handles.edit9,'String',num2str(sh2)); %輸出置信區間的上限
set(handles.edit10,'String',num2str(xi2)); %輸出置信區間的下限
case 2
a=str2num(get(handles.edit1,'string')); %得到用戶輸入的數據
b=str2num(get(handles.edit2,'string'));
aj=mean(a); %得到樣本均值
bj=mean(b);
Sa=var(a); %得到樣本方差
Sb=var(b);
n1=length(a); %得到樣本容量
n2=length(b);
alpha=str2num(get(handles.edit5,'string')); %給定常數alpha
u2a=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分布的雙側分位數
sigma=str2num(get(handles.edit6,'string'));
sigma1=str2num(get(handles.edit7,'string'));
sigma2=str2num(get(handles.edit8,'string'));
if sigma~='X' %從GUI界面的提示可知,若sigma為未知數時均規定輸入'X',若已知則輸入實際值,
%所以可判斷sigma是否已知
f0=0;
else
f0=1;
end
if sigma1~='X' %判斷sigma1是否已知
f1=0;
else
f1=1;
end
if sigma2~='X' %判斷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);
end
set(handles.edit3,'String',num2str(sh)); %輸出置信區間的上限
set(handles.edit4,'String',num2str(xi)); %輸出置信區間的下限
case 3
a=str2num(get(handles.edit1,'string'));
b=str2num(get(handles.edit2,'string'));
aj=mean(a); %得到樣本均值
bj=mean(b);
Sa=var(a); %得到樣本方差
Sb=var(b);
n1=length(a); %得到樣本容量
n2=length(b);
alpha=str2num(get(handles.edit5,'string')); %給定常數alpha
u2a=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);
mu1=str2num(get(handles.edit6,'string'));
mu2=str2num(get(handles.edit7,'string'));
if mu1~='X' %判斷mu1是否已知
f3=0;
else
f3=1;
end
if mu2~='X' %判斷mu2是否已知
f4=0;
else
f4=1;
end
F=finv(alpha/2,n2-1,n1-1); %給定alpha,得到f分布的雙側分位數
if f3==1 & f4==1
sh=F*Sa/Sb;
xi=Sa/Sb*F;
else
msgbox('Error!')
end
set(handles.edit3,'String',num2str(sh)); %輸出置信區間的上限
set(handles.edit4,'String',num2str(xi)); %輸出置信區間的下限
end
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
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)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -