📄 gausview.m
字号:
function fig = gaussview(x,mu,sigma,title,rangeX,rangeY);% GAUSVIEW 2D 啊快矫救 剐档 犬牢 档备%% GAUSVIEW(X,MU,SIGMA,TITLE) % X绰 2瞒盔 钎夯 单捞磐肺 N*2 青纺(茄 青捞 钎夯 基敲 窍唱)% MU绰 剐档狼 乞闭% SIGMA 剐档狼 傍盒魂 青纺% TITLE篮 敲吩狼 力格 %% 滚瓢阑 捞侩窍咯 2D客 3D 焊扁甫 急琶且 荐 乐绊 绵阑 祈笼且 荐档 乐促. % 扼叼坷 滚瓢栏肺 单捞磐 焊扁, 皋浆焊扁, 牧捧绢 焊扁甫 急琶且 荐档 乐促. %if nargin < 2, mu = mean(x); end;if nargin < 3, sigma = cov(x); end;if nargin < 4, title = ''; end;if nargin < 5, rangeX = 0:20:2000; end;if nargin < 6, rangeY = 0:20:2000; end;if isempty(title), fig = figure;else, fig = figure('name',title);end;colordef none;% Make plotsset(gca,'xlim', [rangeX(1) rangeX(end)], ... 'ylim', [rangeY(1) rangeY(end)], ... 'zlim', [0 2.5e-5], ... 'dataAspectRatio', [1 1 1e-8] );pos = get(gca,'position'); pos(1) = pos(1) - 0.1; set(gca,'position',pos);hold on;grid on;rotate3d on;% - cloud of pointshpts = plot(x(:,1),x(:,2),'y+');% - Gaussian mesh[xx,yy] = meshgrid(rangeX,rangeY);zz = gausspdf( [xx(:) yy(:)], mu, sigma );zz = reshape(zz, size(xx));hm = mesh(xx,yy,zz,'facecolor','none');colormap(jet);%set(hm,'visible','off');% - Gaussian contour[c,hc] = contour3(xx,yy,zz,'r-');set(hc,'linewidth',2,'visible','off');% ButtonsbtnX = 0.78;btnWdth = 0.22;btnHt = 0.1;cstr = [ 'if get(gco,''value''), ' ... 'set(get(gco,''userdata''),''visible'',''on'');' ... 'else;' ... 'set(get(gco,''userdata''),''visible'',''off'');' ... 'end;' ... ];hb(1) = uicontrol('style','radio', ... 'units','norm', ... 'pos', [btnX 0.85 btnWdth btnHt], ... 'background', [0.8 0.85 0.8], ... 'foreground', [0 0 0], ... 'string','View data points', ... 'callback', cstr, ... 'userdata', hpts, ... 'value', 1, ... 'visible', 'on');hb(2) = uicontrol('style','radio', ... 'units','norm', ... 'pos', [btnX 0.75 btnWdth btnHt], ... 'background', [0.8 0.85 0.8], ... 'foreground', [0 0 0], ... 'string','View pdf mesh', ... 'callback', cstr, ... 'userdata', hm, ... 'value', 1, ... 'visible', 'on');hb(3) = uicontrol('style','radio', ... 'units','norm', ... 'pos', [btnX 0.65 btnWdth btnHt], ... 'background', [0.8 0.85 0.8], ... 'foreground', [0 0 0], ... 'string','View pdf contour', ... 'callback', cstr, ... 'userdata', hc, ... 'value', 0, ... 'visible', 'on');hb(4) = uicontrol('style','push', ... 'units','norm', ... 'pos', [btnX 0.5 btnWdth btnHt], ... 'background', [0.8 0.85 0.8], ... 'foreground', [0 0 0], ... 'string','2D view', ... 'callback', 'view(2);', ... 'visible', 'on');hb(5) = uicontrol('style','push', ... 'units','norm', ... 'pos', [btnX 0.4 btnWdth btnHt], ... 'background', [0.8 0.85 0.8], ... 'foreground', [0 0 0], ... 'string','3D view', ... 'callback', 'view(3);', ... 'visible', 'on');hb(6) = uicontrol('style','push', ... 'units','norm', ... 'pos', [btnX 0.25 btnWdth btnHt], ... 'background', [0.8 0.85 0.8], ... 'foreground', [0 0 0], ... 'string','Edit axes', ... 'callback', 'axlimdlg;', ... 'visible', 'on');hb(7) = uicontrol('style','push', ... 'units','norm', ... 'pos', [btnX 0.05 btnWdth btnHt], ... 'background', [0.8 0.8 0.8], ... 'foreground', [0 0 0], ... 'string','Close', ... 'callback', 'close(gcf);', ... 'visible', 'on');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -