How can I find the maximum number and minimum number in a matrix?

조회 수: 3 (최근 30일)
zeezo
zeezo 2018년 6월 5일
답변: Stephen23 2018년 6월 5일
I have this matrix
A=
300 300 300 300 300 300
262 262 262 262 262 262
238 218 218 218 218 218
210 192 260 260 260 192
239 221 288 251 251 220
241 223 290 253 245 222
I would like to find the maximum number and minimum number?

채택된 답변

Shrestha Kumar
Shrestha Kumar 2018년 6월 5일
Hi, max(A) returns maximum element in case A is a vector. If A is a matrix then it returns a row vector of the maximum value of each column.
Here, you can do max(max(A)) to get the maximum element.Similarly min(min(A)) to get minimum element.

추가 답변 (1개)

Stephen23
Stephen23 2018년 6월 5일
Where M is your matrix:
max(M(:))
min(M(:))

카테고리

Help CenterFile Exchange에서 Elementary Math에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by