How to generate random matrix from another one?
이전 댓글 표시
Hi!
I have a 18 x 57x11 matrix .
How can I make a new random matrix (the same size) , which is generated by "shuffling" the values of the original matrix?
A lot thanks in advance!
댓글 수: 1
Ha! You got 3 different approaches that use randperm() and reshape().
By the way, your data is not a matrix. A matrix is 2 dimensional, with rows and columns. Your data contains a 3rd dimension which makes it an array. All 3 answers will work no matter how many dimensions are in the input.
채택된 답변
추가 답변 (2개)
Adam
2019년 9월 19일
newMatrix = reshape( oldMatrix( randperm( numel( oldMatrix ) ) ), size( oldMatrix ) );
should work, though I'm sure there are neater ways.
카테고리
도움말 센터 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!