How do I create a Matlab 5x5 matrix of numbers 1-100?

11 vues (au cours des 30 derniers jours)
Julen Vicente Pipaon
Julen Vicente Pipaon le 15 Fév 2021
Modifié(e) : Adam Danz le 16 Fév 2021
I have to make an script that creates a 5x5 matrix of 1-100 numbers in increasing order.

Réponse acceptée

Adam Danz
Adam Danz le 15 Fév 2021
Modifié(e) : Adam Danz le 16 Fév 2021
Use X=randi(100,1,5*5) to get random integers <=100 or x=rand(1,5*5)*100 if you want floating decimals.
Then use sort() to achieve increasing order.
Then reshape the vector back into a 5x5 matrix using reshape().

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by