📄 data_generator2.m
字号:
function [features,targets] = data_generator2(stud_num,N);
%------------------------------------------------------------------
% [features,targets] = data_generator2(stud_num,N)
% DATA_GENERATOR function will help you to generate your own
% artificial test dataset for classification.
% Input variables:
% - stud_num - the last digit of your student number
% - N - number of samples in the feature vector (should be even)
% Output:
% - features - augmented feature vector for two classes of the size (3,N)
% - targets - vector of targets
% --------------------------------------------------
% Evgeny Krestyannikov
% krestyan@cs.tut.fi
% Institute of Signal Processing
% Room TE 313
set1_x=.9*randn(1,N/2);
set1_y=.9*randn(1,N/2);
target1=ones(1,N/2);
class1=[set1_x; set1_y];
c=ones(1,N/2);
class1=[c; class1];
set2_x=5 + .2*randn(1,N/2);
set2_y=1+randn(1,N/2);
target2=ones(1,N/2)*2;
class2=[set2_x ; set2_y];
[p(1,:),p(2,:)] = cart2pol(class2(1,:),class2(2,:));%笛卡尔坐标转化成极坐标theta and rho
p(1,:) = p(1,:)-(pi/6*stud_num);
[class2(1,:),class2(2,:)] = pol2cart(p(1,:),p(2,:));
class2=[c; class2];
features=[class1 class2];
sz = size(features,2);
order=randperm(sz)';
features=features(:,order);
targets=[target1 target2];
targets=targets(1,order);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -