Generation of Random matrices in ascending order

1 visualización (últimos 30 días)
Offroad Jeep
Offroad Jeep el 22 de Oct. de 2016
Comentada: Offroad Jeep el 23 de Oct. de 2016
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.....

Respuesta aceptada

Image Analyst
Image Analyst el 22 de Oct. de 2016
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)

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by