?? generadatos.m
字號:
function [orig,w]= generadatos(K2,m)% K2: number of data;% m; slope of the lineglobal K1 K2% se generan datos linealmente separablesclf[orig,slope]=datasepf(K2,m); % slope is the slope of separating plane% that has the formula: y = slope*x + 0.5*(1-slope)[Km,Kn]=size(orig);M=Kn-1; % number of inputsK0=sum([orig(:,Kn)==-1]); K1=Km-K0; K2=K0+K1;% # of targets = 0 and 1 % slope is the slope of separating plane% that has the formula: y = slope*x + 0.5*(1-slope)% g(x) = 0.5(1-m)+mx-y=w(1) + w(2)*x + w(3)*y w = [0.5*(1-slope) slope -1];figure(1)subplot(1,2,2),plot(orig(1:K1,1),orig(1:K1,2),'*',orig(K1+1:K2,1),orig(K1+1:K2,2),'o')axis('square');gridv=axis;[lx,ly]=sline(w,v);subplot(1,2,1),plot(orig(1:K1,1),orig(1:K1,2),'*',... orig(K1+1:K2,1),orig(K1+1:K2,2),'o',lx,ly)axis('square');gridtitle('separating hyperplane')orig = orig';% w = [slope -1 0.5*(1-slope)]';w = w';
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -