selecting random numbers
조회 수: 4 (최근 30일)
이전 댓글 표시
i have a matrix 10x10 i want to select random matrix of 5x5 but the selected matrix must be in same order as the original matrix,if i choose 20x20 the random matrix must be 10x10
please help
댓글 수: 2
Wayne King
2012년 1월 7일
Can you elaborate on what you mean by "...must be in the same order" In your example all you're telling us is that the row and column dimensions must be 1/2 the original matrix.
채택된 답변
Image Analyst
2012년 1월 7일
Just use rand() to randomly pick a row and column in the range 1 to half the width and extract it subMatrix = fullMatrix(row1:row2, col1:col2); I'm sure you can figure out how to get row1, etc. using rand. (I'm leaving some of the work to you in case this is a homework problem, which it sounds like it is.)
댓글 수: 0
추가 답변 (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!