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

📄 qushi.m

📁 多元统计程序包
💻 M
字号:
function varargout = qushi(varargin)
% QUSHI M-file for qushi.fig
%      QUSHI, by itself, creates a new QUSHI or raises the existing
%      singleton*.
%
%      H = QUSHI returns the handle to a new QUSHI or the handle to
%      the existing singleton*.
%
%      QUSHI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in QUSHI.M with the given input arguments.
%
%      QUSHI('Property','Value',...) creates a new QUSHI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before qushi_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to qushi_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 qushi

% Last Modified by GUIDE v2.5 08-Nov-2003 11:53:27
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @qushi_OpeningFcn, ...
                   'gui_OutputFcn',  @qushi_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin<=1
fig1=openfig('qushi.fig','reuse');
handles1=guihandles(fig1);
guidata(fig1,handles1);
%if nargin==0
 %   check_and_load([],handles1);
 %   elseif exist(varargin{1},handles1)
    %check_and_load(varargin)
if nargin>0
    varargout{1}=fig1;
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 qushi is made visible.
function qushi_OpeningFcn(hObject, eventdata, handles1, 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 qushi (see VARARGIN)

% Choose default command line output for qushi
handles1.output = hObject;

% Update handles structure
guidata(hObject, handles1);

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


% --- Outputs from this function are returned to the command line.
function varargout = qushi_OutputFcn(hObject, eventdata, handles1)
% 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} = handles1.output;
% --- Executes during object creation, after setting all properties.function data_box_CreateFcn(hObject, eventdata, handles1)% 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, handles1)% 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 outputdata_listbox_CreateFcn(hObject, eventdata, handles1)% hObject    handle to outputdata_listbox (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 outputdata_listbox.function outputdata_listbox_Callback(hObject, eventdata, handles1)% hObject    handle to outputdata_listbox (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 outputdata_listbox contents as cell array%        contents{get(hObject,'Value')} returns selected item from outputdata_listbox% --- Executes during object creation, after setting all properties.function answer_text_CreateFcn(hObject, eventdata, handles1)% hObject    handle to answer_text (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 answer_text_Callback(hObject, eventdata, handles1)% hObject    handle to answer_text (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 answer_text as text%        str2double(get(hObject,'String')) returns contents of answer_text as a double% --- Executes on button press in import_button.function import_button_Callback(hObject, eventdata, handles1)% hObject    handle to import_button (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', '打开数据文件');
global data
%如果打开文件对话框的"cancel"按钮被选择
if isequal([fname, pname], [0, 0])
    return
%否则,转载文件全名,包括路径,并检验文件,转载它。
else
    File = fullfile(pname, fname);
    if isempty(File)
        errordlg('您打开的不是一个有效的数据文件');
    end
    if exist(File)==2
    data=importdata(File);
    end 
    set(handles1.import_button,'enable','off');
        set(handles1.run_button,'enable','on');
        set(handles1.data_box,'string',num2str(data));   
        

    end 

  
    


 
% --- Executes on button press in run_button.function run_button_Callback(hObject, eventdata, handles1)% hObject    handle to run_button (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)global data
panduan1=str2num(get(handles1.data_box,'string'));

 if isempty(panduan1)
     errordlg('您打开的数据文件有误,可能为空,可能数据矩阵有不合法的字符或输入!详情请参阅“帮助”');   

 else
[n,m]=size(data);
x=data(:,1:m-1);
z=data(:,m);
%ee1(n,x,y,handles1)X(1:n,:)=1;
M(1:36,1:31)=1;
x1=x(:,1);
x2=x(:,2);
z1=mean(z);
str_1='总的回归平方和S为';
S=sum((z-z1).^2);
p=1;
m=3;
%确定做有效的趋势分析的最高次数
while m<n
    p=p+1;
    m=(p+1)*(p+2)/2;
end
p=p-1;
str_2=['根据观测点数及p次方程的系数确定有效的趋势分析的最高次数为',num2str(p),'次'];
set(handles1.outputdata_listbox,'string',{str_1,num2str(S),str_2});
strall=[];
 
       for i=1:p
    
          [Mx,My]=meshgrid(0:0.2:6,0:0.2:7);        
          [sn,sm]=size(Mx);
          for j=0:i
              X=[X,(x1.^(i-j)).*(x2.^j)];
              M=[M,(Mx.^(i-j)).*(My.^j)];
          end
          str_3=['------二元',num2str(i),'次趋势分析-------'];
          str_4='趋势面方程系数B为';
          B=inv(X'*X)*X'*z;
          str_5='观测点的趋势值Z为';
          Z=X*B;
          [sn1,sm1]=size(M);
          s=sm1/sm;
          fig_Z=0;
          for k=1:s
              sel_a=sm*(k-1)+1;
              sel_b=sm*k;
              fig_Z=fig_Z+(M(:,sel_a:sel_b)*B(k)); 
          end    
          fig1_qs=openfig('qsfigure');       
          [K,L]=contour(Mx,My,fig_Z);
        
         handles1_qs=guihandles(fig1_qs);
         guidata(fig1_qs,handles1_qs);          
          clabel(K,L);
          xlabel(['------二元',num2str(i),'次趋势分析-------'])          
          str_6='剩余平方和Q为';
          Q=sum((z-Z).^2);
          str_7='趋势平方和U为';
          U=S-Q;
          str_8='拟和度C为';
          C=U/S;
          m=(i+1)*(i+2)/2-1;
          str_9='F检验值为';
          F=(U/m)/(Q/(n-m-1));
          str={str_3,str_4,num2str(B),str_5,num2str(Z),str_6,num2str(Q),str_7,num2str(U),str_8,num2str(C),str_9,num2str(F)};
          strall=[strall,str];
          set(handles1.outputdata_listbox,'string',strall);
        
 end
end


% --- Executes on button press in restart_button.function restart_button_Callback(hObject, eventdata, handles1)% hObject    handle to restart_button (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)set(handles1.data_box,'string','');
set(handles1.outputdata_listbox,'string','');

set(handles1.import_button,'enable','on');

set(handles1.run_button,'enable','off');
% --- Executes on button press in exit_button.function exit_button_Callback(hObject, eventdata, handles1)% hObject    handle to exit_button (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)close
%function ee1(n,x,z,handles1)
% --------------------------------------------------------------------function menu_Callback(hObject, eventdata, handles)% hObject    handle to menu (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --------------------------------------------------------------------function menu1_Callback(hObject, eventdata, handles)% hObject    handle to menu1 (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 menu2_Callback(hObject, eventdata, handles, varargin)% hObject    handle to menu2 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)importdata_help; % --- Executes on button press in exit_button.function pushbutton7_Callback(hObject, eventdata, handles, varargin)% hObject    handle to exit_button (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 readresult_button.function readresult_button_Callback(hObject, eventdata, handles1, varargin)% hObject    handle to readresult_button (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)readresult_pushbutton(handles1);% --- Executes on button press in save_button.function save_button_Callback(hObject, eventdata, handles1, varargin)% hObject    handle to save_button (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)save_pushbutton(handles1);% --------------------------------------------------------------------function menu3_Callback(hObject, eventdata, handles, varargin)% hObject    handle to menu3 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)restart_help;% --------------------------------------------------------------------function menu4_Callback(hObject, eventdata, handles, varargin)% hObject    handle to menu4 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)readresult_help;% --------------------------------------------------------------------function menu5_Callback(hObject, eventdata, handles, varargin)% hObject    handle to menu5 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)save_help;% --- Executes during object creation, after setting all properties.function outputdata_button_CreateFcn(hObject, eventdata, handles)% hObject    handle to outputdata_listbox (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 outputdata_listbox.function outputdata_button_Callback(hObject, eventdata, handles)% hObject    handle to outputdata_listbox (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 outputdata_listbox contents as cell array%        contents{get(hObject,'Value')} returns selected item from outputdata_listbox

⌨️ 快捷键说明

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