📄 demo_emgmm.html
字号:
<span class=comment>% 'Callback','demo_emgmm(''loadmodel'',gcf)');
</span><br>
<br> <span class=comment>% == PopUp Menu =====================================================
</span><br> bottom=0.95-height;
<br> htxfeatures=<span class=graph>uicontrol</span>( ...
<br> <span class=quotes>'Style'</span>,<span class=quotes>'text'</span>, ...
<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</span>, ...
<br> <span class=quotes>'Position'</span>,[left bottom width height], ...
<br> <span class=quotes>'String'</span>,<span class=quotes>'Covariance'</span>);
<br> <span class=comment>% popup menu
</span><br> bottom=bottom-height;
<br> hpufeatures=<span class=graph>uicontrol</span>( ...
<br> <span class=quotes>'Style'</span>,<span class=quotes>'popup'</span>, ...
<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</span>, ...
<br> <span class=quotes>'Position'</span>,[left bottom width height], ...
<br> <span class=quotes>'String'</span>,[<span class=quotes>'Diagonal '</span>; <span class=quotes>'Full '</span>]);
<br>
<br> <span class=comment>% == Edit line ==========================================================
</span><br> <span class=comment>% prior info about number of the classes
</span><br> bottom=bottom-1.3*height;
<br> htxclasses=<span class=graph>uicontrol</span>( ...
<br> <span class=quotes>'Style'</span>,<span class=quotes>'text'</span>, ...
<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</span>, ...
<br> <span class=quotes>'Position'</span>,[left bottom width 0.9*height], ...
<br> <span class=quotes>'String'</span>,<span class=quotes>'Components'</span>);
<br> bottom=bottom-height;
<br> hedclasses = <span class=graph>uicontrol</span>(...
<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</span>, ...
<br> <span class=quotes>'ListboxTop'</span>,0, ...
<br> <span class=quotes>'Position'</span>,[left bottom width height], ...
<br> <span class=quotes>'Style'</span>,<span class=quotes>'edit'</span>,...
<br> <span class=quotes>'String'</span>,<span class=quotes>'2'</span>);
<br>
<br> <span class=comment>% Iterations
</span><br> bottom=bottom-1.3*height;
<br> htxiter=<span class=graph>uicontrol</span>( ...
<br> <span class=quotes>'Style'</span>,<span class=quotes>'text'</span>, ...
<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</span>, ...
<br> <span class=quotes>'Position'</span>,[left bottom width 0.9*height], ...
<br> <span class=quotes>'String'</span>,<span class=quotes>'Iterations'</span>);
<br> bottom=bottom-height;
<br> hediter = <span class=graph>uicontrol</span>(...
<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</span>, ...
<br> <span class=quotes>'ListboxTop'</span>,0, ...
<br> <span class=quotes>'Position'</span>,[left bottom width height], ...
<br> <span class=quotes>'Style'</span>,<span class=quotes>'edit'</span>,...
<br> <span class=quotes>'String'</span>,<span class=quotes>'1'</span>);
<br>
<br> <span class=comment>% == CheckBox =========================================================
</span><br>
<br> <span class=comment>% Should the first algorithm step be random or not ?
</span><br> bottom=bottom-height*1.3;
<br> hxbrandom = <span class=graph>uicontrol</span>(...
<br> <span class=quotes>'Style'</span>,<span class=quotes>'checkbox'</span>, ...
<br> <span class=quotes>'Units'</span>,<span class=quotes>'normalized'</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>'Random init'</span>);
<br><br> <span class=comment>%=====================================================================
</span><br> <span class=comment>% Store handlers</span><br> handlers=struct(...<br> <span class=quotes>'ellipse'</span>,struct(<span class=quotes>'handler'</span>,-1,<span class=quotes>'mi'</span>,[],<span class=quotes>'sigma'</span>,[],<span class=quotes>'t'</span>,0,<span class=quotes>'Pk'</span>,[],...<br> <span class=quotes>'solution'</span>,0),...<br> <span class=quotes>'center'</span>,[],...<br> <span class=quotes>'graph1'</span>,struct(<span class=quotes>'handler'</span>,-1,<span class=quotes>'loglik'</span>,[],<span class=quotes>'axist'</span>,0,<span class=quotes>'time'</span>,[]),...<br> <span class=quotes>'title1'</span>,htitle1,...<br> <span class=quotes>'title2'</span>,htitle2,...<br> <span class=quotes>'btSaveModel'</span>,hbtSaveModel,...<span class=comment>% 'btLoadModel',hbtLoadModel,...</span><br> <span class=quotes>'btstep'</span>,hbtstep,...<br> <span class=quotes>'btstop'</span>,hbtstop,... <br> <span class=quotes>'btclose'</span>,hbtclose,...<br> <span class=quotes>'btplay'</span>,hbtplay,...<br> <span class=quotes>'btreset'</span>,hbtreset,...<br> <span class=quotes>'btinfo'</span>,hbtinfo,...<br> <span class=quotes>'btload'</span>,hbtload,...<br> <span class=quotes>'btcreat'</span>,hbtcreat,... <span class=comment>%%% 'console',hconsole,...</span><br> <span class=quotes>'txsteps'</span>,htxsteps,...<br> <span class=quotes>'txclasses'</span>,htxclasses,...<br> <span class=quotes>'txiter'</span>,htxiter,...<br> <span class=quotes>'txfeatures'</span>,htxfeatures,...<br> <span class=quotes>'pufeatures'</span>,hpufeatures,...<br> <span class=quotes>'editer'</span>,hediter,...<br> <span class=quotes>'xbrandom'</span>,hxbrandom,...<br> <span class=quotes>'axes1'</span>,haxes1,...<br> <span class=quotes>'axes2'</span>,haxes2,...<br> <span class=quotes>'edclasses'</span>,hedclasses);<br> <span class=graph>set</span>(hfigure,<span class=quotes>'UserData'</span>,handlers)<br><br> <span class=comment>% Reset</span><br> demo_emgmm(<span class=quotes>'reset'</span>,hfigure);<br><br> <span class=comment>% Put figure on desktop</span><br> <span class=graph>set</span>(hfigure,<span class=quotes>'Visible'</span>,<span class=quotes>'on'</span>);<br> drawnow;<br><br> <span class=label>case</span> <span class=quotes>'savemodel'</span><br> <span class=comment>% == Save model ============================================</span><br><br> h=<span class=graph>get</span>(hfigure,<span class=quotes>'UserData'</span>);<br> <br> <span class=keyword>if</span> h.ellipse.t == 0,<br> errordlg(<span class=quotes>'No model has found yet.'</span>,<span class=quotes>'No model to save'</span>,<span class=quotes>'modal'</span>);<br> <span class=jump>return</span>;<br> <span class=keyword>end</span><br> <br> [name,path]=uiputfile(<span class=quotes>'*.mat'</span>,<span class=quotes>'Save model'</span>);<br> <span class=keyword>if</span> name ~= 0,<br>
<br> Mean = h.ellipse.mi;
<br> Cov = reshape(h.ellipse.sigma,2,2,size(Mean,2));
<br> Prior = h.ellipse.Pk;<br> fun = <span class=quotes>'pdfgmm'</span>;<br> save(strcat(path,name),<span class=quotes>'Mean'</span>,<span class=quotes>'Cov'</span>,<span class=quotes>'Prior'</span>,<span class=quotes>'fun'</span>);
<br> <br> <span class=keyword>end</span> <br> <br> <span class=label>case</span> <span class=quotes>'loadmodel'</span><br> <span class=comment>% == Load model ============================================</span><br><br> h=<span class=graph>get</span>(hfigure,<span class=quotes>'UserData'</span>);<br> sets=<span class=graph>get</span>(h.axes1,<span class=quotes>'UserData'</span>);<br><br> <span class=comment>% Are data sets loaded ?</span><br> <span class=keyword>if</span> isempty(sets)==1,
<br> <span class=comment>% no warning is needy because of the huge topic on the screen:))).</span><br> <span class=jump>return</span>;<br> <span class=keyword>end</span><br> <br> [name,path]=uigetfile(<span class=quotes>'*.mat'</span>,<span class=quotes>'Load model'</span>);<br> <span class=keyword>if</span> name ~= 0,<br><br> fname=strcat(path,name);<br><span class=comment>% if checkdat(fname,DATA_IDENT,2,0)==1,</span><br><br> demo_emgmm(<span class=quotes>'reset'</span>,hfigure);<br> <br> model=load(fname);<br> <br> <span class=keyword>if</span> <span class=stack>exist</span>(<span class=quotes>'model.Pk'</span>)==0,<br> <span class=comment>% suppose uniformly distributed Pk</span><br> model.Pk=ones(1,sum(model.K))/sum(model.K);<br> <span class=keyword>end</span><br> <br> h.ellipse.mi = model.MI;<br> h.ellipse.sigma=model.SIGMA;<br> h.ellipse.Pk = model.Pk;<br> <br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -