MATLAB: How to create a Matlab 5×5 matrix of numbers 1-100

matrixmatrix arraymatrix manipulation

I have to make an script that creates a 5×5 matrix of 1-100 numbers in increasing order.

Best Answer

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().