Generation of Random matrices in ascending order

조회 수: 1 (최근 30일)
Offroad Jeep
Offroad Jeep 2016년 10월 22일
댓글: Offroad Jeep 2016년 10월 23일
Hi to all the matlab users. I want to generate 5 matrices of 3X3. the initial matrix is having all zeros. then the next 5 matrices that are generated should have random elements between 0 to pi but in ascending order at their respective loctions. e.g i am giving example 1st element of 1st matrix 0 1st element of 2nd matrix 0.0034 1st element of 3rd matrix 0.0139 1st element of 4th matrix 0.9861 1st element of 5th matrix 1.2345 1st element of 6th matrix 2.8904
similarly for other element.... Note: the element at same location of matrices are ascending. I hope I am able to clarify the question.
Regards.....

채택된 답변

Image Analyst
Image Analyst 2016년 10월 22일
This will do it:
% Get all 5 matrices in one 3D array in sorted order.
m3d = sort(pi * rand(3,3,5), 3)
% Extract out 5 separate, individual matrices.
matrix1 = m3d(:, :, 1)
matrix2 = m3d(:, :, 2)
matrix3 = m3d(:, :, 3)
matrix4 = m3d(:, :, 4)
matrix5 = m3d(:, :, 5)

추가 답변 (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