fcfx2.asv

来自「多元统计程序包」· ASV 代码 · 共 331 行

ASV
331
字号
function varargout = fcfx2(varargin)
% FCFX2 M-file for fcfx2.fig
%      FCFX2, by itself, creates a new FCFX2 or raises the existing
%      singleton*.
%
%      H = FCFX2 returns the handle to a new FCFX2 or the handle to
%      the existing singleton*.
%
%      FCFX2('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in FCFX2.M with the given input arguments.
%
%      FCFX2('Property','Value',...) creates a new FCFX2 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before fcfx2_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to fcfx2_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

% Edit the above text to modify the response to help fcfx2

% Last Modified by GUIDE v2.5 02-Nov-2003 10:07:37
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @fcfx2_OpeningFcn, ...
                   'gui_OutputFcn',  @fcfx2_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin<=1
fig2=openfig('fcfx2.fig','reuse');
handles2=guihandles(fig2);
guidata(fig2,handles2);
if nargin>0
    varargout{1}=fig2;
end
elseif ischar(varargin{1})
    try
        [varargout{1:nargout}]=feval(varargin{:});
    catch
        disp(lasterr);
    end
end

% End initialization code - DO NOT EDIT


% --- Executes just before fcfx2 is made visible.
function fcfx2_OpeningFcn(hObject, eventdata, handles2, 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 fcfx2 (see VARARGIN)

% Choose default command line output for fcfx2
handles2.output = hObject;

% Update handles structure
guidata(hObject, handles2);

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


% --- Outputs from this function are returned to the command line.
function varargout = fcfx2_OutputFcn(hObject, eventdata, handles2)
% 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} = handles2.output;
% --------------------------------------------------------------------function Uimenu1_Callback(hObject, eventdata, handles2)% hObject    handle to Uimenu1 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --------------------------------------------------------------------function um1_item1_Callback(hObject, eventdata, handles2)% hObject    handle to um1_item1 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)str='在一项试验中多于一个因素对试验结果有影响,就叫做双因素方差分析';
msgbox(str)
% --------------------------------------------------------------------function um1_item2_Callback(hObject, eventdata, handles2)% hObject    handle to um1_item2 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)str='原始数据为m×n的矩阵,其中列n代表因素1,行m代表有多于一个观测点的因素2';
msgbox(str)
% --------------------------------------------------------------------function um1_item3_Callback(hObject, eventdata, handles2)% hObject    handle to um1_item3 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)openfig('fcfx2_help2','reuse');% --- Executes on button press in import_botton.function import_botton_Callback(hObject, eventdata, handles2)% hObject    handle to import_botton (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)[fname, pname] = uigetfile('*.mat', '打开数据文件');
%如果打开文件对话框的"cancel"按钮被选择
if isequal([fname, pname], [0, 0])
    return
%否则,转载文件全名,包括路径,并检验文件,转载它。
else
    File = fullfile(pname, fname);
    %如果MAT文件有效的,存储文件名
  % if Check_And_Load(File, handls)
   %      handles.LastFile = File;
    %     guidata(fig1, handles)
    if isempty(File)
        errordlg('您打开的不是一个有效的数据文件');
    end
    if exist(File)==2
    data=importdata(File);
    end
  
        set(handles2.data_box,'string',num2str(data));
      
        set(handles2.import_botton,'enable','off');
        set(handles2.ok_button,'enable','on')
   
end
panduan1=get(handles2.data_box,'string');
 if isempty(panduan1)
    errordlg('您打开的数据文件有误,详情请参阅“帮助”的“数据说明”');
 end

%判断输入数据是否为空
%panduan1=get(handles2.data_box,'string');
% if ~isempty(panduan1)
     %非空,关闭“导入数据”按钮
    % set(handles2.import_botton,'enable','off');      
    % prompt='请输入每个“单元”中的观测量的个数';
    % reps=inputdlg(prompt);
     %判断观测点值是否输入,若输入则起用“运行”按钮
    % if ~isempty(reps)
   %  set(handles2.run_botton,'enable','on');   
     %else
       %  error='您必须输入观测点的个数,否则程序无法运行.您要输入观测的点的个数,以继续程序吗?';
      %   answer=questdlg( error,'提示','是的','取消','是的');
      %   switch answer
             %case '是的'
                  % reps=inputdlg(prompt);
                  % if isempty(reps{1})
                    %  errordlg('由于您没有输入观测点的个数,程序将无法运行','警告','modal')               
                   %  set(handles2.import_botton,'enable','off');
                     % set(handles2.run_botton,'enable','off')
                      %   else
                   %   set(handles2.run_botton,'enable','on');
                      % end
                  % if isempty(reps)
                   %   errordlg('由于您没有输入观测点的个数,程序将无法运行','警告','modal')               
                  %    set(handles2.import_botton,'enable','off');
                  %    set(handles2.run_botton,'enable','off')
                      % end
                  % return
                   %case '取消'
                   %errordlg('由于您没有输入观测点的个数,程序将无法运行','警告','modal')               
                   %set(handles2.import_botton,'enable','off');
                 % set(handles2.run_botton,'enable','off')
                 %  return
                   %end
           % end
   
function [var,n,m,r]=get_var_names(handles2,File)

data=importdata(File); 
     var=data;   
     input={'请输入因素A的水平数:','请输入因素B的水平数:','请输入重复实验的次数:'}; 
     reps=inputdlg(input);
     n=str2num(reps{1});
     m=str2num(reps{2});
     r=str2num(reps{3});
% --- Executes on button press in run_botton.function run_botton_Callback(hObject, eventdata, handles2)% hObject    handle to run_botton (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)global x r
p=anova2(x,r);
str_p=num2str(p);
set(handles2.result_box,'string',str_p);
panduan2=get(handles2.result_box,'string');
if ~isempty(panduan2)
    set(handles2.run_botton,'enable','off');
   
end
% --- Executes on button press in restart_botton.function restart_botton_Callback(hObject, eventdata, handles2)% hObject    handle to restart_botton (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)set(handles2.data_box,'string','');
set(handles2.result_box,'string','');
set(handles2.import_botton,'enable','on');set(handles2.run_botton,'enable','off');
set(handles2,ok_button,'enable','off');
% --- Executes on button press in exit_botton.function exit_botton_Callback(hObject, eventdata, handles2)% hObject    handle to exit_botton (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)close% --- Executes during object creation, after setting all properties.function data_box_CreateFcn(hObject, eventdata, handles2)% hObject    handle to data_box (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: listbox controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on selection change in data_box.function data_box_Callback(hObject, eventdata, handles2)% hObject    handle to data_box (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 data_box contents as cell array%        contents{get(hObject,'Value')} returns selected item from data_box% --- Executes during object creation, after setting all properties.function result_box_CreateFcn(hObject, eventdata, handles2)% hObject    handle to result_box (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: listbox controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on selection change in result_box.function result_box_Callback(hObject, eventdata, handles2)% hObject    handle to result_box (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 result_box contents as cell array%        contents{get(hObject,'Value')} returns selected item from result_box% --- Executes during object creation, after setting all properties.function reps_edit_CreateFcn(hObject, eventdata, handles)% hObject    handle to reps_edit (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    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction reps_edit_Callback(hObject, eventdata, handles)% hObject    handle to reps_edit (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 reps_edit as text%        str2double(get(hObject,'String')) returns contents of reps_edit as a double% --- Executes on button press in ok_button.function ok_button_Callback(hObject, eventdata, handles2)% hObject    handle to ok_button (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)global File x r
   [var,n,m,r]=get_var_names(handles2,File);
if (size(var)==[n*r,m])
    x=var;
    
    set(handles2.data_box,'string',{'数据矩阵为:',num2str(x)});
     set(handles2.run_botton,'enable','on');
     set(handles2.ok_button,'enable','off');
elseif (size(var)==[m*r,n]) 
    x=var;
   
     set(handles2.data_box,'string',{'数据矩阵为:',num2str(x)});
     set(handles2.run_botton,'enable','on');
     set(handles2.ok_button,'enable','off');
else 
    errordlg('您输入的的数据与m、n和r不匹配,请重新选择变量。若要重新导入数据文件请单击“重新开始”');
end
end

 

⌨️ 快捷键说明

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