Matlab生成二类线性可分数据

%% 生成二类线性可分数据
function [feature, category]=generate_sample(step,error)
aa=3; %斜率
bb=3; %截距
b1=1;
rr =error;
s=step; x1(:,1) = -1:s:1;
n = length(x1(:,1));
x1(:,2) = aa.*x1(:,1) + bb + b1 + rr*abs(randn(n,1));
y1 = -ones(n,1);
x2(:,1) = -1:s:1;
x2(:,2) = aa.*x2(:,1) + bb - b1 - rr*abs(randn(n,1));
y2 = ones(n,1);
%figure;
%plot(x1(:,1),x1(:,2),'bx',x2(:,1),x2(:,2),'k.');
feature=[x1;x2];
category=[y1;y2];
上一篇:django实现自定义manage命令的扩展


下一篇:使用模板类导致error LNK2019: 无法解析的外部符号