Generation of Random matrices in ascending order
1 次查看(过去 30 天)
显示 更早的评论
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.....
0 个评论
采纳的回答
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 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!