📄 demo_linclass.html
字号:
<span class=comment>%%%</span><br> sets.I=sets.y;<br> sets.N=2;<br> <span class=keyword>for</span> ii=1:max(sets.y),<br> sets.K(ii)=length(find(sets.y==ii));<br> <span class=keyword>end</span><br><br> <span class=comment>% store loaded sets</span><br> <span class=graph>set</span>(h.axes1,<span class=quotes>'UserData'</span>,sets);<br><br> <span class=comment>% set axes according to current point set</span><br> win=cmpwin(min(sets.X<span class=quotes>'),max(sets.X'</span>),BORDER,BORDER);<br> setaxis(h.axes1,win);<br><br> <span class=graph>axes</span>(h.axes1);<br><br> <span class=comment>% plots points</span><br><span class=comment>%% ppoints(sets.X,sets.I);</span><br> ppatterns(sets);<br><br> drawnow;<br> <br><span class=label>case</span> <span class=quotes>'play'</span><br> <span class=comment>% == Start up the adaptation process ============================</span><br><br> <span class=comment>% Get handle to data.</span><br> h=<span class=graph>get</span>(hfigure,<span class=quotes>'UserData'</span>); <br><br> <span class=keyword>if</span> h.<span class=graph>line</span>.handler==-1,<br> <span class=jump>return</span>;<br> <span class=keyword>end</span><br><br> <span class=comment>% Check if data are loaded.</span><br> sets=<span class=graph>get</span>(h.axes1,<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>% Disable and enable buttons.</span><br> <span class=graph>set</span>([h.btinfo h.btstep h.btclose h.btplay h.btreset h.btload h.btcreat ...<br> h.pualgo h.editer],<span class=quotes>'Enable'</span>,<span class=quotes>'off'</span>);<br> <span class=graph>set</span>(h.btstop,<span class=quotes>'Enable'</span>,<span class=quotes>'on'</span>);<br><br> <span class=graph>set</span>(h.btstop,<span class=quotes>'UserData'</span>,0);<br><br> h.stop = 0;<br> <span class=graph>set</span>(hfigure,<span class=quotes>'UserData'</span>,h);<br> <br> <span class=comment>% Play - adaptation process</span><br> <span class=keyword>while</span> h.stop==0 & <span class=graph>get</span>(h.btstop,<span class=quotes>'UserData'</span>)==0,<br> demo_linclass(<span class=quotes>'step'</span>,hfigure);<br> h=<span class=graph>get</span>(hfigure,<span class=quotes>'UserData'</span>); <br> <span class=keyword>end</span><br><br> <span class=comment>% Enable and dissable buttons.</span><br> <span class=graph>set</span>([h.btinfo h.btstep h.btclose h.btplay h.btreset h.pualgo ...<br> h.editer h.btload h.btcreat],<span class=quotes>'Enable'</span>,<span class=quotes>'on'</span>);<br> <span class=graph>set</span>(h.btstop,<span class=quotes>'Enable'</span>,<span class=quotes>'off'</span>);<br><br><br><span class=label>case</span> <span class=quotes>'step'</span><br> <span class=comment>% == Perform one adaptation step ======================================</span><br> h=<span class=graph>get</span>(hfigure,<span class=quotes>'UserData'</span>); <span class=comment>% get handlers we will need...</span><br><br> <span class=keyword>if</span> h.<span class=graph>line</span>.handler==-1,<br> <span class=jump>return</span>;<br> <span class=keyword>end</span><br><br> <span class=comment>% get sets</span><br> sets=<span class=graph>get</span>(h.axes1,<span class=quotes>'UserData'</span>);<br><br> <span class=comment>% no data set loaded</span><br> <span class=keyword>if</span> isempty(sets)==1,<br> <span class=jump>return</span>;<br> <span class=keyword>end</span><br><br> [alpha,theta,solution,t]=exec(hfigure);<br><br> <span class=keyword>if</span> mod(h.stepcnt,2)==1 & h.<span class=graph>line</span>.t >0, <br> <span class=keyword>if</span> solution ~= 1,<br> demo_linclass(<span class=quotes>'drawline'</span>,hfigure,theta,alpha);<br> <span class=keyword>else</span><br> text=makeinfo(t,alpha,theta,solution);<br> <span class=graph>set</span>(h.console,<span class=quotes>'String'</span>,text );<br> <span class=keyword>end</span> <br> <span class=keyword>else</span><br> <span class=keyword>if</span> <span class=graph>get</span>(h.xbanim,<span class=quotes>'Value'</span>)==0,<br> demo_linclass(<span class=quotes>'drawline'</span>,hfigure,theta,alpha);<br> <span class=keyword>else</span><br> demo_linclass(<span class=quotes>'animline'</span>,hfigure,theta,alpha);<br> <span class=keyword>end</span><br> <br> <span class=keyword>if</span> solution==1 | solution==-1,<br> h.stop=1;<br> <span class=keyword>end</span><br> h.<span class=graph>line</span>.alpha = alpha;<br> h.<span class=graph>line</span>.theta = theta;<br> h.<span class=graph>line</span>.t = t;<br> <br> <span class=keyword>if</span> solution==0 | solution ==1,<br> <span class=comment>% appear time and line parameters</span><br> text=makeinfo(t,alpha,theta,solution);<br> <span class=keyword>elseif</span> solution==-1,<br> text=<span class=io>sprintf</span>(<span class=quotes>'Solution does not exist.\n'</span>);<br> <span class=keyword>end</span> <br> <span class=graph>set</span>(h.console,<span class=quotes>'String'</span>,text );<br> <span class=keyword>end</span><br><br><br> <span class=comment>% store new solution</span><br> h.stepcnt=h.stepcnt+1;<br> <span class=graph>set</span>(hfigure,<span class=quotes>'UserData'</span>,h);<br><br><br><span class=label>case</span> <span class=quotes>'animline'</span><br> <span class=comment>% == Smooth transition of line from old to new position ===============</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>% old position of line is...</span><br> alpha2=h.<span class=graph>line</span>.alpha;<br> theta2=h.<span class=graph>line</span>.theta;<br> t2=h.<span class=graph>line</span>.t;<br><br> <span class=comment>% New position get from input arguments</span><br> theta1=<span class=stack>varargin</span>{1};<br> alpha1=<span class=stack>varargin</span>{2};<br><br> <span class=keyword>if</span> t2~=0,<br> <span class=comment>% move line</span><br> step=1/ANIM_STEPS;<br> <span class=keyword>for</span> k=0:step:1,<br> alpha=(1-k)*alpha2+k*alpha1; <span class=comment>% smooth transition of alpha</span><br> theta=(1-k)*theta2+k*theta1; <span class=comment>% --//-- theta</span><br><br> demo_linclass(<span class=quotes>'drawline'</span>,hfigure,theta,alpha);<br> <span class=keyword>end</span><br> <span class=keyword>else</span><br> <span class=comment>% it is first step</span><br> demo_linclass(<span class=quotes>'drawline'</span>,hfigure,theta1,alpha1); <span class=comment>% first step</span><br> <span class=keyword>end</span> <span class=comment>% if t2~=0</span><br><br><br><span class=label>case</span> <span class=quotes>'reset'</span><br> <span class=comment>% == Reset adaptation process, set up zero step ================</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 data set</span><br> sets=<span class=graph>get</span>(h.axes1,<span class=quotes>'UserData'</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>% zeroize parameters of the separation line</span><br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -