selecting random numbers

15 次查看(过去 30 天)
kash
kash 2012-1-7
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
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.
kash
kash 2012-1-7
yes wayne the row and column dimensions must be 1/2 the original matrix.
must be in same order the the original matrix in is ascending order ,so i want the same order

请先登录,再进行评论。

采纳的回答

Image Analyst
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 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by