Switch two random elements in a vector
显示 更早的评论
How do I randomly change two elements in a vector?
For example, I start with x1=randperm(42) Then I want x2 to equal x1, except with two of those numbers randomly switched
Thank you
1 个评论
Stephen23
2017-11-4
@Jermaine Garcia: what happens if the two random picked elements randomly happen to pick the same element? Or, to put it another way, do you want to exclude the possibility that no elements are swapped?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 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!