Randomly generate a vector containing integers. Extract items from odd positions using a single command line
이전 댓글 표시
Hi guys. How can i randomly generate a vector containing integers and extract items from odd positions using a single command line?
Thank you!
채택된 답변
추가 답변 (1개)
Walter Roberson
2022년 3월 3일
struct('d',randi(100,1,1)).d(1:2:end)
Does not require that the number of values is even.
Seems pointless to me unless you are carefully controlling the random seed. Just wastes time and is unclear. The numbers are not more random by taking every second one instead of all of them.
카테고리
도움말 센터 및 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!