
Matlab数学常用的调用函数.docx
14页max %求最大值Largest elements in arraySyntaxC = max(A)C = max(A,B)C = max(A,[],dim)[C,I] = max(...)DescriptionC = max(A) returns the largest elements along different dimensions of an array.If A is a vector, max(A) returns the largest element in A.A=[1 2 3;4 5 6;7 8 9]A =123456789max(A)ans =789If A is a matrix, max(A) treats the columns of A as vectors, returning a row vector containing the maximum element from each column.If A is a multidimensional array, max(A) treats the values along the first non-singleton dimension as vectors, returning the maximum value of each vector.C = max(A,B) returns an array the same size as A and B with the largest elements taken from A or B. The dimensions of A and B must match, or they may be scalar.B=[7 8 9;10 11 12;13 14 15]B =789101112131415C=max(A,B)C =789101112131415C = max(A,[],dim) returns the largest elements along the dimension of A specified by scalar dim. For example, max(A,[],1) produces the maximum values along the first dimension (the rows) of A.C=max(A,[],1)C =7 8 9C=max(A,[],2)C =3619[C,I] = max(...) finds the indices(指标 index 的复数) of the maximum values of A, and returns them in output vector I. If there are several identical maximum values, the index of the first one found is returned.[C I]=max(A)C =7 8 9I =3 3 3RemarksFor complex input A, max returns the complex number with the largest complex modulus(magnitude), computed with max(abs(A)). Then computes the largest phase angle withmax(angle(x)), if necessary.The max function ignores NaNs.A=[i 2i 1+3i;5-i 6i 8+0.5i]A =0 + 1.0000i0 + 2.0000i1.0000 + 3.0000i5.0000 - 1.0000i0 + 6.0000i8.0000 + 0.5000imax(A) %求得是 A 中模最大的元素ans=5.0000 - 1.0000i0 + 6.0000i8.0000 + 0.5000iabs(A)ans=1.00002.00003.16235.09906.00008.0156max(abs(A))ans=5.09906.00008.0156max(angle(A))ans=1.57081.57081.2490angle(A)ans=1.57081.57081.2490-0.19741.57080.0624min %求最小值Smallest elements in arraySyntaxC = min(A)C = min(A,B)2C = min(A,[],dim)[C,I] = min(...)DescriptionC = min(A) returns the smallest elements along different dimensions of an array.If A is a vector, min(A) returns the smallest element in A.If A is a matrix, min(A) treats the columns of A as vectors, returning a row vector containing the minimum element from each column.If A is a multidimensional array, min operates along the first nonsingleton dimension.C = min(A,B) returns an array the same size as A and B with the smallest elements taken from A or B. The dimensions of A and B must match, or they may be scalar.C = min(A,[],dim) returns the smallest elements along the dimension of A specified by scalar dim. For example, min(A,[],1) produces the minimum values along the first dimension (the rows) of A.[C,I] = min(...) finds the indices of the minimum values of A, and returns them in output vector I. If there are several identical minimum values, the index of the first one found is returned.RemarksFor complex input A, min returns the complex number with the smallest complexmodulus (magnitude), computed with min(abs(A)). Then computes the smallest phaseangle with min(angle(x)), if necessary.The min function ignores NaNs.mean %平均值Average or mean value of arraySyntaxM = mean(A)M = mean(A,dim)DescriptionM = mean(A) returns the mean values of the elements along different dimensions of an array.If A is a vector, mean(A) returns the mean value of A.If A is a matrix, mean(A) treats the columns of A as vectors, returning a row vector of mean values.If A is a multidimensional array, mean(A) treats the values along the first non-singleton dimension as vectors, returning an array of mean values.M = mean(A,dim) returns the mean values for elements along the dimension of A specified by scalar dim. For matrices, mean(A,2) is a column vector containing the mean value of each row.ExamplesA = [1 2 3; 3 3 6; 4 6 8; 4 7 7]A =1233364683477mean(A)ans =3.00004.50006.0000mean(A,2)ans =2466median %中位数Median value of arraySyntaxM = median(A)M = median(A,dim)DescriptionM = median(A) returns the median values of the elements along different dimensions of an array. A should be of type single or double.If A is a vector, median(A) returns the median value of A.If A is a matrix, median(A) treats the columns of A as vectors, returning a row vector of median values.If A is a multidimensional array, median(A) treats the values along the first nonsingleton dimension as vectors, returning an 。
