📄 demo_anderson.html
字号:
<span class=comment>% == Edit lines ================================================================</span><br><br> bottom=0.95-3.5*height;<br> <span class=comment>% Precision of solution</span><br> htxprec=<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>,PREC_TITLE(1,:));<br><br> bottom=bottom-height;<br> hedprec = <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>,num2str(DEF_PRECISION(1)) );<br><br> <span class=comment>% # of iterations</span><br> bottom=bottom-1.5*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><br> bottom=bottom-0.9*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>,1);<br><br> <span class=comment>% ==============================================================================</span><br><br> <span class=comment>% Store handlers</span><br> handlers=struct(...<br> <span class=quotes>'line'</span>,struct(<span class=quotes>'handler'</span>,-1,<span class=quotes>'alpha'</span>,0,<span class=quotes>'alpha1'</span>,0,<span class=quotes>'alpha2'</span>,0,<span class=quotes>'lambda'</span>,0,<span class=quotes>'theta'</span>,0,<span class=quotes>'t'</span>,0),...<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,...<br> <span class=quotes>'pualgo'</span>,hpualgo,...<br> <span class=quotes>'console'</span>,hconsole,...<br> <span class=quotes>'edprec'</span>,hedprec,...<br> <span class=quotes>'editer'</span>,hediter,...<br> <span class=quotes>'txprec'</span>,htxprec,...<br> <span class=quotes>'axes1'</span>,haxes1,...<br> <span class=quotes>'xbanim'</span>,hxbanim);<br><br> <span class=graph>set</span>(hfigure,<span class=quotes>'UserData'</span>,handlers);<br><br> <span class=comment>% Reset adaptation, t=0</span><br> demo_anderson(<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><br> drawnow;<br><br><br><span class=label>case</span> <span class=quotes>'creatdata'</span><br> <span class=comment>% == Invoke data set creator ============================================</span><br><span class=comment>% creatset('normal',2,'demo_anderson','created',hfigure);</span><br><br> createdata(<span class=quotes>'gauss'</span>,2,<span class=quotes>'demo_anderson'</span>,<span class=quotes>'created'</span>,hfigure);<br><br><span class=label>case</span> <span class=quotes>'created'</span><br> <span class=comment>% == Load new created data set ===========================================</span><br><br> <span class=comment>% get handler and make this figure active</span><br> <span class=graph>figure</span>(hfigure);<br> h=<span class=graph>get</span>(hfigure,<span class=quotes>'UserData'</span>);<br><br> <span class=comment>% get file name</span><br> path=<span class=stack>varargin</span>{1};<br> name=<span class=stack>varargin</span>{2};<br> pathname=strcat(path,name);<br><br><span class=comment>% if checkdat(pathname,DATA_IDENT,2,[0 0])==1,</span><br> <span class=keyword>if</span> check2dgauss(pathname),<br> file.pathname=pathname;<br> file.path=path;<br> file.name=name;<br> <span class=graph>set</span>(h.btload,<span class=quotes>'UserData'</span>,file);<br> demo_anderson(<span class=quotes>'loadsets'</span>,hfigure);<br> demo_anderson(<span class=quotes>'reset'</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><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 apropriate data, if yes 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('anderson');</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 0])==1,</span><br> <span class=keyword>if</span> check2dgauss(file.pathname),<br> <span class=graph>set</span>(h.btload,<span class=quotes>'UserData'</span>,file);<br> demo_anderson(<span class=quotes>'loadsets'</span>,hfigure);<br> demo_anderson(<span class=quotes>'reset'</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>'algohandler'</span><br> <span class=comment>% == Handler for check box 'Algorithm' =======================================</span><br> <span class=comment>% If new algorithm is selected then prepare data for it.</span><br><br> h=<span class=graph>get</span>(hfigure,<span class=quotes>'UserData'</span>);<br><br> <span class=keyword>if</span> <span class=graph>get</span>(h.pualgo,<span class=quotes>'UserData'</span>) ~= <span class=graph>get</span>(h.pualgo,<span class=quotes>'Value'</span>),<br> <span class=graph>set</span>(h.pualgo,<span class=quotes>'UserData'</span>,<span class=graph>get</span>(h.pualgo,<span class=quotes>'Value'</span>));<br><br> <span class=graph>set</span>(h.edprec,<span class=quotes>'String'</span>,num2str(DEF_PRECISION(<span class=graph>get</span>(h.pualgo,<span class=quotes>'Value'</span>))) );<br> <span class=graph>set</span>(h.txprec,<span class=quotes>'String'</span>,PREC_TITLE(<span class=graph>get</span>(h.pualgo,<span class=quotes>'Value'</span>),:));<br><br> demo_anderson(<span class=quotes>'loadsets'</span>,hfigure);<br> demo_anderson(<span class=quotes>'reset'</span>,hfigure);<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 given file name and load the data set from him.</span><br><br> h=<span class=graph>get</span>(hfigure,<span class=quotes>'UserData'</span>); <span class=comment>% uicontrol handlers</span><br><br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -