How do I sample a random value from a matrix?
5 次查看(过去 30 天)
显示 更早的评论
Let's say I have a random matrix:
A = rand(10,4)
How can I sample a random value from this matrix (without replacement)? Essentially how can I perform a randsample but for a matrix instead of a vector?
0 个评论
采纳的回答
Akira Agata
2018-5-2
If you want to obtain k samples randomly from A, the following will do that.
ind = randperm(numel(A),k);
output = A(ind);
更多回答(0 个)
另请参阅
类别
在 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!