Select random numbers from a matrix

12 views (last 30 days)
Pei Jia
Pei Jia on 16 Dec 2017
I want to select 100 random numbers from a certain column of a matrix. What should I do?

Answers (1)

Image Analyst
Image Analyst on 16 Dec 2017
Try this:
y = rand(1000, 3); % Some random data
% Select 100 numbers randomly from column 2:
selected = y(randperm(size(y, 1), 100), 2)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!