i have a vector which contain 23 elements.i wanna choose 20 elements among this 23 elements randomly.how can i do this?
2 views (last 30 days)
Show older comments
fariba amini
on 19 Apr 2016
Commented: fariba amini
on 19 Apr 2016
i have a vector which contain 23 elements.i wanna choose 20 elements among this 23 elements randomly.how can i do this?
0 Comments
Accepted Answer
Azzi Abdelmalek
on 19 Apr 2016
Edited: Azzi Abdelmalek
on 19 Apr 2016
A=randi(50,1,23)
out = A(randperm(23,20))
3 Comments
Azzi Abdelmalek
on 19 Apr 2016
Edited: Azzi Abdelmalek
on 19 Apr 2016
out = A(sort(randperm(23,20)))
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!