Generating two classes of points
Show older comments
Hi,
I want to create a 100x2 feature vector set, with roughly half in class '1' and the rest in class '-1'. (As in, when I make a scatter plot of the x-y coordinates, the points should be almost linearly separable). I suppose rand or randn wouldn't help much here.
Thanks for your inputs.
Accepted Answer
More Answers (1)
Image Analyst
on 20 Feb 2018
No, but randperm() can help. Try this:
m = zeros(100, 2); % Initialize to all zero.
indexes = randperm(numel(m), numel(m)/2) % Get half of the indexes to change to 1.
m(indexes) = 1 % Change them to 1.
1 Comment
Deepayan Bhadra
on 20 Feb 2018
Categories
Find more on Random Number Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!