generadatos.m
来自「Diversos ejemplos sobre la aplicacion de」· M 代码 · 共 38 行
M
38 行
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 + =
减小字号Ctrl + -
显示快捷键?