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

조회 수: 13 (최근 30일)
Julen Vicente Pipaon
Julen Vicente Pipaon 2021년 2월 15일
편집: Adam Danz 2021년 2월 16일
I have to make an script that creates a 5x5 matrix of 1-100 numbers in increasing order.

채택된 답변

Adam Danz
Adam Danz 2021년 2월 15일
편집: Adam Danz 2021년 2월 16일
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().

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