swaping 2 random numbers from array
1 次查看(过去 30 天)
显示 更早的评论
hello,
I have an array x = [1,(randperm(20)+1)]
but i would like to swap 2 random numbers of that array while keeping 1 as my first integer
please let me know how to go about that
0 个评论
采纳的回答
Bruno Luong
2022-4-28
ij = randperm(length(x)-1,2)+1;
x(ij) = x(flip(ij));
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!