📄 createdata.html
字号:
<html><head> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1"> <title>createdata.m</title><link rel="stylesheet" type="text/css" href="../../m-syntax.css"></head><body><code><span class=defun_kw>function</span> <span class=defun_out>result </span>= <span class=defun_name>createdata</span>(<span class=defun_in>action,varargin</span>)
<br><span class=h1>% CREATEDATA Interactive data generator.
</span><br><span class=help>%
</span><br><span class=help>% <span class=help_field>Synopsis:</span></span><br><span class=help>% createdata
</span><br><span class=help>% createdata('finite')
</span><br><span class=help>% createdata('finite',num_classes)
</span><br><span class=help>% createdata('gauss')
</span><br><span class=help>% createdata('gauss',num_distrib)
</span><br><span class=help>%
</span><br><span class=help>% <span class=help_field>Description:</span></span><br><span class=help>% createdata or createdata('finite') invokes an interactive generator
</span><br><span class=help>% of finite point sets in 2D. The generated points can be assigned
</span><br><span class=help>% into two classes (1,2). The generator saves data to a
</span><br><span class=help>% specified file. The file has the following fields:
</span><br><span class=help>% X [2 x num_data] 2D vectors.
</span><br><span class=help>% y [1 x num_data] Assigned labels.
</span><br><span class=help>%
</span><br><span class=help>% createdata('finite',num_classes) when num_classes is specified
</span><br><span class=help>% then the points can be assigned labels from 1 to num_classes.
</span><br><span class=help>%
</span><br><span class=help>% createdata('gauss') invokes an interactive generator of
</span><br><span class=help>% Gaussian distributions. A user can specify mean vector and
</span><br><span class=help>% covariance matrix. The generator saves data to a file
</span><br><span class=help>% having the following fields:
</span><br><span class=help>% Mean [2 x ncomp] Mean vectors.
</span><br><span class=help>% Cov [2 x 2 x ncomp] Covariance matrices.
</span><br><span class=help>% y [1 x ncomp] Assigned labels.
</span><br><span class=help>%
</span><br><span class=help>% createdata('gauss',num_classes) when num_classes is specified
</span><br><span class=help>% then the distributions can be assigned labels from 1 to num_classes.
</span><br><span class=help>%
</span><br><span class=help>% The data generator is controlled by mouse:
</span><br><span class=help>% Left button ... creates a new point or Gaussian.
</span><br><span class=help>% Right button ... erases the focused point or Gaussian.
</span><br><span class=help>%
</span><br><span class=help>% In the case of generating Gaussians left button double-click makes
</span><br><span class=help>% selected Gaussian focused. The covariance matrix of focused
</span><br><span class=help>% Gaussian can be modified.
</span><br><span class=help>%
</span><br><hr><br><span class=help1>% <span class=help1_field>About:</span> Statistical Pattern Recognition Toolbox
</span><br><span class=help1>% (C) 1999-2003, Written by Vojtech Franc and Vaclav Hlavac
</span><br><span class=help1>% <a href="http://www.cvut.cz">Czech Technical University Prague</a>
</span><br><span class=help1>% <a href="http://www.feld.cvut.cz">Faculty of Electrical Engineering</a>
</span><br><span class=help1>% <a href="http://cmp.felk.cvut.cz">Center for Machine Perception</a>
</span><br><br><span class=help1>% <span class=help1_field>Modifications:</span>
</span><br><span class=help1>% 01-may-2004, VF
</span><br><span class=help1>% 13-Feb-2003, VF
</span><br><br><br><hr>XCOLORS=[<span class=quotes>'r'</span>,<span class=quotes>'b'</span>,<span class=quotes>'g'</span>,<span class=quotes>'m'</span>,<span class=quotes>'c'</span>,<span class=quotes>'k'</span>,<span class=quotes>'y'</span>]; <span class=comment>% colors of the ellipses
</span><br>MAXCOLOR=size(XCOLORS,2);
<br>ID_NORMAL=<span class=quotes>'Infinite sets, Normal distributions'</span>;
<br>ID_FINITE=<span class=quotes>'Finite sets, Enumeration'</span>;
<br>DX_SPACE=0.5; <span class=comment>% space betwean the nearest point and the left and right border
</span><br>DY_SPACE=0.5; <span class=comment>% --//-- top and bottom -//-
</span><br>
<br><span class=keyword>if</span> <span class=stack>nargin</span> < 1,
<br> action = <span class=quotes>'finite'</span>;
<br><span class=keyword>end</span>
<br>
<br><span class=keyword>switch</span> lower(action)
<br><span class=label>case</span> <span class=quotes>'finite'</span>
<br> <span class=comment>% == We will create finite data sets ===================================
</span><br> <span class=keyword>if</span> <span class=stack>nargin</span> < 2,
<br> K=2;
<br> <span class=keyword>else</span>
<br> K=<span class=stack>varargin</span>{1};
<br> <span class=keyword>end</span>
<br> createdata(<span class=quotes>'initialize'</span>,action,K,<span class=stack>varargin</span>{2:<span class=stack>nargin</span>-1});
<br>
<br><span class=label>case</span> <span class=quotes>'gauss'</span>
<br> <span class=comment>% == We will create gaussian distributed sets ===========================
</span><br> <span class=keyword>if</span> <span class=stack>nargin</span> < 2,
<br> K=2;
<br> <span class=keyword>else</span>
<br> K=<span class=stack>varargin</span>{1};
<br> <span class=keyword>end</span>
<br> createdata(<span class=quotes>'initialize'</span>,action,K,<span class=stack>varargin</span>{2:<span class=stack>nargin</span>-1});
<br>
<br>
<br><span class=label>case</span> <span class=quotes>'initialize'</span>
<br> <span class=comment>% == Initialize dialog window =========================================
</span><br>
<br> <span class=comment>% get input arguments
</span><br> K=<span class=stack>varargin</span>{2};
<br>
<br> <span class=comment>% == Figure ===========================================================
</span><br> hfigure = <span class=graph>figure</span>(...
<br> <span class=quotes>'Visible'</span>,<span class=quotes>'off'</span>,...
<br> <span class=quotes>'NumberTitle'</span>,<span class=quotes>'off'</span>, ...
<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</span>, ...
<br> <span class=quotes>'RendererMode'</span>,<span class=quotes>'manual'</span>);
<br>
<br> <span class=comment>% == Axes =============================================================
</span><br> haxes1= <span class=graph>axes</span>(...
<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</span>, ...
<br> <span class=quotes>'ButtonDownFcn'</span>,<span class=quotes>'createdata('</span><span class=quotes>'click'</span><span class=quotes>',gcf)'</span>,...
<br> <span class=quotes>'Box'</span>,<span class=quotes>'on'</span>, ...
<br> <span class=quotes>'XGrid'</span>,<span class=quotes>'on'</span>, ...
<br> <span class=quotes>'YGrid'</span>,<span class=quotes>'on'</span>, ...
<br> <span class=quotes>'NextPlot'</span>,<span class=quotes>'add'</span>,...
<br> <span class=quotes>'Position'</span>,[0.1 0.1 0.65 0.85]);
<br> <span class=graph>axis</span>([-1 1 -1 1]);
<br> xlabel(<span class=quotes>'X'</span>);
<br> ylabel(<span class=quotes>'Y'</span>);
<br>
<br>
<br> <span class=comment>% == Buttons ==========================================================
</span><br> left=0.8;
<br> bottom=0.05;
<br> height=0.05;
<br> width=0.15;
<br>
<br> <span class=comment>% close button
</span><br> hbtclose = <span class=graph>uicontrol</span>( ...
<br> <span class=quotes>'Units'</span>,<span class=quotes>'Normalized'</span>, ...
<br> <span class=quotes>'Callback'</span>,<span class=quotes>'createdata('</span><span class=quotes>'close'</span><span class=quotes>',gcf)'</span>,...
<br> <span class=quotes>'ListboxTop'</span>,0, ...
<br> <span class=quotes>'Position'</span>,[left bottom width height], ...
<br> <span class=quotes>'String'</span>,<span class=quotes>'Close'</span>);
<br>
<br> <span class=comment>% ok button
</span><br> bottom=bottom+1*height;
<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -