Select random numbers from a matrix
12 次查看(过去 30 天)
显示 更早的评论
I want to select 100 random numbers from a certain column of a matrix. What should I do?
回答(1 个)
Image Analyst
2017-12-16
Try this:
y = rand(1000, 3); % Some random data
% Select 100 numbers randomly from column 2:
selected = y(randperm(size(y, 1), 100), 2)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!