How to get the min and max values of a randomized matrix?
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Anthony Koning
am 19 Sep. 2022
Kommentiert: Chunru
am 20 Sep. 2022
Hellow. I'm currently making a 20x20 matrix where each value of the matrix is a random number between 0-128, as well as fincing the largest and smallest values generated by said matrix. However, whenever I use the M=min/max(A) functions, my min/max values keep remaining the same (97 for min and 116 for max) despite the matrix generating numbers greater and smaller than those two values. Could someone explain why this is happening?
0 Kommentare
Akzeptierte Antwort
Chunru
am 19 Sep. 2022
A = randi([0 128], [20, 20])
maxA = max(A(:))
minA = min(A(:))
2 Kommentare
Chunru
am 20 Sep. 2022
I am not sure what you have exactly done since you did not post your code.
Here is my guess: max(A(:)) or max(A, [], 'all') find max of all elements of A while max(A) find the max along column of A.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!