Matlab 函数收集整理

时间:2022-07-21 17:58:09

randperm

p = randperm(n),返回从1到n的整数,随机排列

p = randperm(n,k),返回从1到n的数中的k个唯一的整数

    randperm(6)

might be the vector

[3  2  6  4  1  5]
randperm(6,3)
might be the vector
[4 2 5]


max

M = max(A) returns the largest elements of A.

  • If A is a vector, then max(A) returns the largest element of A.

  • If A is a matrix, then max(A) is a row vector containing the maximum value of each column.

  • If A is a multidimensional array, then max(A) operates along the first array dimension whose size does not equal 1, treating the elements as vectors. The size of this dimension becomes 1 while the sizes of all other dimensions remain the same. If A is an empty array whose first dimension has zero length, then max(A)returns an empty array with the same size as A.


M = max(A,[],dim) returns the largest elements along dimension dim. For example, if A is a matrix, then max(A,[],2) is a column vector containing the maximum value of each row.