📄 xiezhh8.m
字号:
function varargout = xiezhh8(varargin)
% XIEZHH8 M-file for xiezhh8.fig
% XIEZHH8, by itself, creates a new XIEZHH8 or raises the existing
% singleton*.
%
% H = XIEZHH8 returns the handle to a new XIEZHH8 or the handle to
% the existing singleton*.
%
% XIEZHH8('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in XIEZHH8.M with the given input arguments.
%
% XIEZHH8('Property','Value',...) creates a new XIEZHH8 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before xiezhh8_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to xiezhh8_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 xiezhh8
% Last Modified by GUIDE v2.5 08-Aug-2007 17:12:58
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @xiezhh8_OpeningFcn, ...
'gui_OutputFcn', @xiezhh8_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 xiezhh8 is made visible.
function xiezhh8_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 xiezhh8 (see VARARGIN)
% Choose default command line output for xiezhh8
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes xiezhh8 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
userdata.x=1;
userdata.y=0;
set(gcf,'userdata',userdata)
% --- Outputs from this function are returned to the command line.
function varargout = xiezhh8_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 button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
userdata=get(gcf,'userdata');
x=userdata.x;
y=userdata.y;
edit3_handle=findobj(gcf,'tag','edit3');
edit4_handle=findobj(gcf,'tag','edit4');
edit5_handle=findobj(gcf,'tag','edit5');
edit6_handle=findobj(gcf,'tag','edit6');
if length(x)>=2&length(y)>=2
x=x(2:end);
y=y(2:end);
if length(x)~=length(y)
warndlg('两样本数据应等长');
else
covxy=cov(x,y);
if length(covxy)>1
set(edit3_handle,'string',num2str(covxy(1,1)));
set(edit4_handle,'string',num2str(covxy(1,2)));
set(edit5_handle,'string',num2str(covxy(2,1)));
set(edit6_handle,'string',num2str(covxy(2,2)));
else
set(edit3_handle,'string',num2str(covxy(1,1)));
end
end
else
warndlg('样本数据均不能为空');
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
edit_handle=findobj(gcf,'tag','edit1');
userdata=get(gcf,'userdata');
value=userdata.x;
x=get(edit_handle,'string');
x=str2num(x);
x=x(:)';
if value(1)==0.01
if ~isempty(x)
userdata.x=[0,x];
set(gcf,'userdata',userdata);
end
else
if ~isempty(x)
userdata.x=[value x];
set(gcf,'userdata',userdata);
end
end
set(edit_handle,'string','');
% --- 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
edit_handle=findobj(gcf,'tag','edit2');
userdata=get(gcf,'userdata');
value=userdata.y;
x=get(edit_handle,'string');
x=str2num(x);
x=x(:)';
if value(1)==0.01
if ~isempty(x)
userdata.y=[0,x];
set(gcf,'userdata',userdata);
end
else
if ~isempty(x)
userdata.y=[value x];
set(gcf,'userdata',userdata);
end
end
set(edit_handle,'string','');
% --- 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
% --- 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)
userdata=get(gcf,'userdata');
value=userdata.x;
value(1)=0.01;
%ny=length(value);
x=value(2:end);
edit_handle=findobj(gcf,'tag','edit1');
set(edit_handle,'string',num2str(x));
userdata.x=value;
set(gcf,'userdata',userdata);
% --- 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)
userdata=get(gcf,'userdata');
value=userdata.x;
value=[0];
userdata.x=value;
set(gcf,'userdata',userdata);
edit_handle=findobj(gcf,'tag','edit1');
set(edit_handle,'string','');
% --- 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)
userdata=get(gcf,'userdata');
value=userdata.y;
value(1)=0.01;
%ny=length(value);
x=value(2:end);
edit_handle=findobj(gcf,'tag','edit2');
set(edit_handle,'string',num2str(x));
userdata.y=value;
set(gcf,'userdata',userdata);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -