?? pfish2d.m
字號(hào):
function [handler]=pfish2d(alphas,handler)% PFISH2D plots boundaries of Fisher's classifier in 2D.% [handler]=pfish2d(alphas,handler)%% PFISH2D plots boundaries of the Fisher's classifier in 2D.% See fishdemo for the example of use.%% Input:% alphas [2xK] contains K vectors determining the classifer (cones).% handler [...] contains handlers of used graphics objects.%% Output:% handler [...] handlers to used graphics objects.%% See also FISHDEMO, FISHERP, FISHERK.%% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz% Written Vojtech Franc (diploma thesis) 12.10.1999, 23.12.1999% Modifications% 26-June-2001, V. Franc, comments repared.% 24. 6.00 V. Hlavac, comments polished.alphas=alphas';% number of linesanum=size(alphas,1);%% Computes angles of the vectors alphas %%angles=[];for i=1:anum, normal=norm(alphas(i,:)); % norm. vector alpha if normal~=0, alpha=alphas(i,:)/normal; angle=acos(alpha(1)); if alphas(i,2) < 0, angle=2*pi-angle; end else
angle=0;
end
angles=[angles;angle];
end
%% Sort the alphas according to the angle %%
[angles,index]=sort(angles);
sortalphas=alphas;
for i=1:anum,
if index(i) ~= i,
sortalphas(i,:)=alphas(index(i),:);
end
end
alphas=sortalphas;
if nargin == 1,
% first tlotting, create lines
% Get current axes
window=axis;
handler=zeros(anum*2,1);
handler=[handler;gca];
alpha0=alphas(anum,:);
j=1;
for i=1:anum,
% draw border among the two vectors alpha
alpha1=alphas(i,:);
alpha=alpha0-alpha1;
alpha=[-alpha(2) alpha(1)];
[x,y]=cliplin2(alpha,window);
handler(j)=line([0 x],[0 y],...
'Color','k',...
'EraseMode','XOR',...
'LineStyle','--');
j=j+1;
% draw vector alpha
[x,y]=cliplin2(alphas(i,:),window);
% 'Color',XCOLORS(mod(index(i)-1,size(XCOLORS,2))+1),...
handler(j)=line([0 x],[0 y],...
'Color',color(index(i)),...
'LineWidth',2,...
'Marker','none',...
'EraseMode','XOR');
j=j+1;
% If the alpha1 is equal to zero then don`t appear her.
if sum(alpha1) == 0,
set([handler(j-1) handler(j-2)],'Visible','off');
end
alpha0=alpha1;
end
elseif nargin == 2,
% second and/or latter plotting, update line properties
window=getaxis(handler(size(handler,1)));;
% plots decision boundaries and the vectrost alphas
j=1;
alpha0=alphas(anum,:);
for i=1:anum,
% plots decision boundary between two classes determined by the alphas
alpha1=alphas(i,:);
alpha=alpha0-alpha1;
alpha=[-alpha(2) alpha(1)];
[x,y]=cliplin2(alpha,window);
% clear old line
set(handler(j),'Visible','off');
% plot new one
if sum(alpha1) == 0,
set(handler(j),'XData',[0 x],'YData',[0 y]);
else
set(handler(j),'XData',[0 x],'YData',[0 y],'Visible','on');
end
j=j+1;
% computes line of the vector alpha
[x,y]=cliplin2(alpha1,window);
% clear old line
set(handler(j),'Visible','off');
% plot new line
if sum(alpha1) == 0,
set(handler(j),'XData',[0 x],'YData',[0 y],'Color',color(index(i)));
else
set(handler(j),'XData',[0 x],'YData',[0 y],'Color',color(index(i)),'Visible','on');
end
j=j+1;
alpha0=alpha1;
end
end
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -