📄 xiezhh3.m
字号:
function varargout = xiezhh3(varargin)
% XIEZHH3 M-file for xiezhh3.fig
% XIEZHH3, by itself, creates a new XIEZHH3 or raises the existing
% singleton*.
%
% H = XIEZHH3 returns the handle to a new XIEZHH3 or the handle to
% the existing singleton*.
%
% XIEZHH3('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in XIEZHH3.M with the given input arguments.
%
% XIEZHH3('Property','Value',...) creates a new XIEZHH3 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before xiezhh3_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to xiezhh3_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 xiezhh3
% Last Modified by GUIDE v2.5 06-Sep-2006 19:38:02
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @xiezhh3_OpeningFcn, ...
'gui_OutputFcn', @xiezhh3_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 xiezhh3 is made visible.
function xiezhh3_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 xiezhh3 (see VARARGIN)
% Choose default command line output for xiezhh3
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes xiezhh3 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = xiezhh3_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;
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
edit1_handle=findobj(gcf,'tag','edit1');
set(edit1_handle,'string','')
edit2_handle=findobj(gcf,'tag','edit2');
set(edit2_handle,'string','')
edit3_handle=findobj(gcf,'tag','edit3');
set(edit3_handle,'string','')
edit4_handle=findobj(gcf,'tag','edit4');
set(edit4_handle,'string','')
edit5_handle=findobj(gcf,'tag','edit5');
set(edit5_handle,'string','')
edit6_handle=findobj(gcf,'tag','edit6');
set(edit6_handle,'string','')
% 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)
% 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
function 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
function edit5_Callback(hObject, eventdata, handles)
% hObject handle to edit5 (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 edit5 as text
% str2double(get(hObject,'String')) returns contents of edit5 as a double
% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (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 edit6_Callback(hObject, eventdata, handles)
% hObject handle to edit6 (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 edit6 as text
% str2double(get(hObject,'String')) returns contents of edit6 as a double
% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (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)
edit1_handle=findobj(gcf,'tag','edit1');
n1=get(edit1_handle,'string');
n1=str2num(n1);
edit2_handle=findobj(gcf,'tag','edit2');
n2=get(edit2_handle,'string');
n2=str2num(n2);
edit3_handle=findobj(gcf,'tag','edit3');
n3=get(edit3_handle,'string');
n3=str2num(n3);
edit4_handle=findobj(gcf,'tag','edit4');
n4=get(edit4_handle,'string');
n4=str2num(n4);
edit5_handle=findobj(gcf,'tag','edit5');
n5=get(edit5_handle,'string');
n5=str2num(n5);
edit6_handle=findobj(gcf,'tag','edit6');
n6=get(edit6_handle,'string');
n6=str2num(n6);
if ~isempty(n1)&~isempty(n2)&~isempty(n3)&~isempty(n4)&~isempty(n5)&~isempty(n6)
if n3<=0|n6<=0|n4~=n5|n3*n6<=n4*n5
warndlg('请正确输入二元正态分布的参数');
else
mu=[n1,n2];
sigma=[n3 n4;n5 n6];
si1=sqrt(n3);
si2=sqrt(n6);
[x,y]=meshgrid(n1-3*si1:6*si1/100:n1+3*si1,n2-3*si2:6*si2/100:n2+3*si2);
xy=[x(:) y(:)];
p=mvnpdf(xy,mu,sigma);
p=reshape(p,size(x));
figure(1)
surf(x,y,p)
xlabel('X')
ylabel('Y')
zlabel('f(x,y)')
end
else
warndlg('参数不能为空');
end
%set(edit1_handle,'string','')
%set(edit2_handle,'string','')
%set(edit3_handle,'string','')
%set(edit4_handle,'string','')
%set(edit5_handle,'string','')
%set(edit6_handle,'string','')
% --- 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)
%edit1_handle=findobj(gcf,'tag','edit1');
%edit2_handle=findobj(gcf,'tag','edit2');
%edit3_handle=findobj(gcf,'tag','edit3');
%edit4_handle=findobj(gcf,'tag','edit4');
%edit5_handle=findobj(gcf,'tag','edit5');
%edit6_handle=findobj(gcf,'tag','edit6');
%set(edit1_handle,'string','')
%set(edit2_handle,'string','')
%set(edit3_handle,'string','')
%set(edit4_handle,'string','')
%set(edit5_handle,'string','')
%set(edit6_handle,'string','')
figure(1)
close
% --- 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)
close 二元正态分布
shiyan
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -