Home > Common Problem > body text

What is the function of function max

(*-*)浩
Release: 2019-07-26 11:56:39
Original
17656 people have browsed it

Function The max function is used to find the largest element of a vector or matrix, or the maximum value among several specified values.

What is the function of function max

There are three forms commonly used in high-level programming languages ​​such as MATLAB: max(A), max(A,B), max(A,[],dim). (Recommended learning: PHP video tutorial)

Function The max function is used to find the maximum element of a vector or matrix, or the maximum value among several specified values. There are three commonly used forms:

(1) max(A):

The input parameter A can be a vector or matrix. If it is a vector, all values ​​in the vector will be returned. The maximum value of the element; if it is a matrix, a row vector is returned, and each element in the vector is the maximum value of each column element of the matrix.

(2) max(A,B):

Compare the sizes of corresponding elements in A and B. A and B can be matrices or vectors, and the sizes must be the same , returns a matrix or vector composed of the larger elements in A and B. In addition, one of A and B can also be a scalar, and the matrix or vector obtained after comparing with the scalar is returned.

(3) max(A,[],dim):

Returns the maximum value of the dim dimension in A.

Usage

If the parameter in the MAX function is an incorrect value or text that cannot be converted to a number, an error will be generated. If the argument is an array or reference, only the numbers in the array or reference will be evaluated. Blank cells, logical values, or text in arrays or references are ignored. If logical values ​​and text cannot be ignored, use the MAXA function instead.

If the argument does not contain a number, the function MAX returns 0.

Example 1: If A1:A5 contains the numbers 10, 7, 9, 27 and 2, then:

MAX(A1:A5) is equal to 27

MAX(A1 :A5,30) is equal to 30

Example 2: If A1=71, A2=83, A3=76, A4=49, A5=92, A6=88, A7=96.

The formula "=MAX(A1:A7)" returns 96.

Example 3: When calculating class hours, if there are less than 60 people in a teaching class, it will be calculated as 60 people. If there are more than 60 people, the class hours will be increased by 0.006 for every more than 1 person.

The formula is =1 MAX(A1-60,0)*0.006

For more PHP related technical articles, please visit the PHP Graphic Tutorial column to learn!

The above is the detailed content of What is the function of function max. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template