unique – Find unique elements of vector
b = unique(A) b = unique(A, 'rows') [b, m, n] = unique(...) [b, m, n] = unique(..., occurrence)
b = unique(A) returns the same values as in A but with no repetitions. A can be a numeric or character array or a cell array of strings. If A is a vector or an array, b is a vector of unique values from A. If A is a cell array of strings, b is a cell vector of unique strings from A. The resulting vector b is sorted in ascending order and its elements are of the same class as A.
sum – Sum of array elements
B = sum(A) B = sum(A,dim) B = sum(..., 'double') B = sum(..., dim,'double') B = sum(..., 'native') B = sum(..., dim,'native')
B = sum(A) returns sums along different dimensions of an array. If A is floating point, that is double or single, B is accumulated natively, that is in the same class as A, and B has the same class as A. If A is not floating point, B is accumulated in double and B has class double.
If A is a vector, sum(A) returns the sum of the elements.
If A is a matrix, sum(A) treats the columns of A as vectors, returning a row vector of the sums of each column.
If A is a multidimensional array, sum(A) treats the values along the first non-singleton dimension as vectors, returning an array of row vectors.
B = sum(A,dim) sums along the dimension of A specified by scalar dim. The dim input is an integer value from 1 to N, where N is the number of dimensions in A. Set dim to 1 to compute the sum of each column, 2 to sum rows, etc.
B = sum(…, ‘double’) and B = sum(…, dim,’double’) perform additions in double-precision and return an answer of type double, even if A has data type single or an integer data type. This is the default for integer data types.
times – Array multiply
c = a.*b c = times(a,b)
c = a.*b multiplies arrays a and b element-by-element and returns the result in c. Inputs a and b must have the same size unless one is a scalar.
c = times(a,b) is called for the syntax a.*b when a or b is an object.
logical – Convert numeric values to logical
K = logical(A)
K = logical(A) returns an array that can be used for logical indexing or logical tests.
A(B), where B is a logical array that is the same size as A, returns the values of A at the indices where the real part of B is nonzero.
A(B), where B is a logical array that is smaller than A, returns the values of column vector A(:) at the indices where the real part of column vector B(:) is nonzero.
>> A= [1 2 3; 4 5 6; 7 8 9;2 0 2] A = 1 2 3 4 5 6 7 8 9 2 0 2 >> logical(A) ans = 1 1 1 1 1 1 1 1 1 1 0 1