📄 demo_mmgauss.html
字号:
topp = model.upper_bound(<span class=keyword>end</span>);<br> h.ellipse.N = model.Alpha;<br> h.ellipse.t = model.t;<br><br> text=<span class=io>sprintf</span>(<span class=quotes>'iteration t=%d '</span>,h.ellipse.t);<br> <span class=keyword>if</span> solution==1,<br> text=strcat(text,<span class=quotes>',solution was found.'</span>);<br> <span class=keyword>else</span><br> <span class=comment>% add new value to plot</span><br> h.plot1.time=[h.plot1.time,h.ellipse.t];<br> h.plot2.minps=[h.plot2.minps,minp];<br> h.plot1.topps=[h.plot1.topps,topp];<br><br> <span class=comment>% is axis to be changed ?</span><br> <span class=keyword>if</span> h.ellipse.t > h.plot1.axist,<br> h.plot1.axist=h.ellipse.t+iter*AXIST_ADD;<br> <span class=graph>set</span>(h.aprob,<span class=quotes>'XLim'</span>,[1 h.plot1.axist]);<br> <span class=keyword>end</span><br> <span class=graph>set</span>(h.plot2.handler,<span class=quotes>'XData'</span>,h.plot1.time,<span class=quotes>'YData'</span>,h.plot2.minps,<span class=quotes>'Visible'</span>,<span class=quotes>'on'</span>);<br> <span class=graph>set</span>(h.plot1.handler,<span class=quotes>'XData'</span>,h.plot1.time,<span class=quotes>'YData'</span>,h.plot1.topps,<span class=quotes>'Visible'</span>,<span class=quotes>'on'</span>);<br><br> <span class=comment>% erase old ellipse, compute and plot new one</span><br> <span class=graph>set</span>(h.ellipse.center,<span class=quotes>'XData'</span>,mi(1),<span class=quotes>'YData'</span>,mi(2),<span class=quotes>'Visible'</span>,<span class=quotes>'on'</span>);<br> r=sqrt(max(mahalan(sets.X,mi,sigma)));<br><span class=comment>%%% [x,y]=ellipse(inv(sigma),50,r,mi);</span><br> [x,y]=ellips(mi,inv(sigma),r,40);<br> <span class=graph>set</span>(h.ellipse.handler,<span class=quotes>'XData'</span>,x,<span class=quotes>'YData'</span>,y,<span class=quotes>'Visible'</span>,<span class=quotes>'on'</span>);<br> <span class=keyword>end</span><br><br> <span class=comment>% comment</span><br> <span class=graph>set</span>(h.txsteps,<span class=quotes>'String'</span>,text);<br><br> <span class=comment>% flush it on desktop</span><br> drawnow;<br><br> <span class=graph>set</span>(hfigure,<span class=quotes>'UserData'</span>,h);<br><br><br><span class=label>case</span> <span class=quotes>'redraw'</span><br> <span class=comment>% == Redraw contents of axes ====================================</span><br><br> h=<span class=graph>get</span>(hfigure,<span class=quotes>'UserData'</span>); <span class=comment>% uicontrol handlers</span><br><br> <span class=comment>% get sets with points</span><br> sets=<span class=graph>get</span>(h.aset,<span class=quotes>'UserData'</span>);<br> <span class=keyword>if</span> isempty(sets)==1,<br> <span class=jump>return</span>;<br> <span class=keyword>end</span><br><br> <span class=comment>% clears axes</span><br> <span class=graph>axes</span>(h.aset);<br> <span class=graph>set</span>(<span class=graph>get</span>(h.aset,<span class=quotes>'Children'</span>),<span class=quotes>'EraseMode'</span>,<span class=quotes>'normal'</span>);<br> <span class=comment>%%% cla;</span><br> clrchild(h.aset);<br> h.ellipse.handler=<span class=graph>plot</span>([0],[0],...<br> <span class=quotes>'Parent'</span>,h.aset,<span class=quotes>'LineWidth'</span>,LINE_WIDTH,...<br> <span class=quotes>'EraseMode'</span>,<span class=quotes>'xor'</span>,<span class=quotes>'Color'</span>,<span class=quotes>'r'</span>,<span class=quotes>'Visible'</span>,<span class=quotes>'off'</span>);<br> h.ellipse.center=<span class=graph>line</span>(0,0,<span class=quotes>'Marker'</span>,<span class=quotes>'+'</span>,...<br> <span class=quotes>'EraseMode'</span>,<span class=quotes>'xor'</span>,<span class=quotes>'Color'</span>,<span class=quotes>'r'</span>,<span class=quotes>'MarkerSize'</span>,CENTERSIZE,<span class=quotes>'Visible'</span>,<span class=quotes>'off'</span>);<br><br> win=cmpwin(min(sets.X<span class=quotes>'),max(sets.X'</span>),BORDER,BORDER);<br><span class=comment>%%% axis(win);</span><br> setaxis(h.aset,win);<br> <span class=graph>axes</span>(h.aset);<br><br> <span class=comment>% plot mixture</span><br><span class=comment>%% pplot(sets.X,sets.I);</span><br><span class=comment>%% ppoints(sets.X,sets.I);</span><br> ppatterns(sets.X);<br><br> <span class=graph>set</span>(hfigure,<span class=quotes>'UserData'</span>,h);<br><br><span class=label>case</span> <span class=quotes>'getfile'</span><br> <span class=comment>% == Invoke standard open file dialog ====================================</span><br> <span class=comment>% Opens file and checks if contains appropriate data, if yes than loads data.</span><br><br> h=<span class=graph>get</span>(hfigure,<span class=quotes>'UserData'</span>);<br><br> <span class=comment>% change path to directory</span><br><span class=comment>%% wres=what('minimax');</span><br><span class=comment>%% cd(wres.path);</span><br><br> [name,path]=uigetfile(<span class=quotes>'*.mat'</span>,<span class=quotes>'Open file'</span>);<br> <span class=keyword>if</span> name~=0,<br> file.pathname=strcat(path,name);<br> file.path=path;<br> file.name=name;<br><span class=comment>% if checkdat(file.pathname,DATA_IDENT,2,[0])==1,</span><br> <span class=keyword>if</span> check2ddata(file.pathname),<br> <span class=graph>set</span>(h.btload,<span class=quotes>'UserData'</span>,file);<br> demo_mmgauss(<span class=quotes>'loadsets'</span>,hfigure);<br> <span class=keyword>else</span><br> errordlg(<span class=quotes>'This file does not contain required data.'</span>,<span class=quotes>'Bad file'</span>,<span class=quotes>'modal'</span>);<br> <span class=keyword>end</span><br> <span class=keyword>end</span><br><br><br><span class=label>case</span> <span class=quotes>'loadsets'</span><br> <span class=comment>% == Load sets ==================================================================</span><br> <span class=comment>% Get file name from the pop up menu according to menu pointer.</span><br><br> h=<span class=graph>get</span>(hfigure,<span class=quotes>'UserData'</span>);<br><br> <span class=comment>% Get file name with sets</span><br> file=<span class=graph>get</span>(h.btload,<span class=quotes>'UserData'</span>);<br><br> <span class=comment>% Load sets</span><br> sets=load(file.pathname);<br> sets.I = sets.y;<br> sets.K = size(sets.X,2);<br> sets.N = 2;<br><br> <span class=comment>% store loaded sets</span><br> <span class=graph>set</span>(h.aset,<span class=quotes>'UserData'</span>,sets);<br><br> <span class=comment>% call reset</span><br> demo_mmgauss(<span class=quotes>'reset'</span>,hfigure);<br><br> <span class=comment>% call redraw</span><br> demo_mmgauss(<span class=quotes>'redraw'</span>,hfigure);<br><br> drawnow;<br><br><br><span class=label>case</span> <span class=quotes>'reset'</span><br> <span class=comment>% == Reset adaptation process, set up t=0 ================</span><br><br> h=<span class=graph>get</span>(hfigure,<span class=quotes>'UserData'</span>); <span class=comment>% get handlers</span><br><br> <span class=comment>% get file</span><br> file=<span class=graph>get</span>(h.btload,<span class=quotes>'UserData'</span>);<br><br> <span class=comment>% get data set</span><br> sets=<span class=graph>get</span>(h.aset,<span class=quotes>'UserData'</span>);<br><br> <span class=comment>% zeroes parameters of the separation line</span><br> h.ellipse.mi=[];<br> h.ellipse.sigma=[];<br> h.ellipse.t=0;<br> h.ellipse.N=[];<br> h.plot1.topps=[];<br> h.plot2.minps=[];<br> h.plot1.time=[];<br> h.plot1.axist=0;<br><br> <span class=comment>% comment</span><br> text=<span class=io>sprintf</span>(<span class=quotes>'iteration t=0 '</span>);<br> <span class=graph>set</span>(h.txsteps,<span class=quotes>'String'</span>,text);<br><br> <span class=comment>% hide ellipse</span><br> <span class=keyword>if</span> h.ellipse.handler==-1,<br> h.ellipse.handler=<span class=graph>plot</span>([0],[0],...<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -