有用的Matlab内置函数(4)

unique – Find unique elements of vector
Syntax

b = unique(A)
b = unique(A, 'rows')
[b, m, n] = unique(...)
[b, m, n] = unique(..., occurrence)

Description
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

Syntax

B = sum(A)
B = sum(A,dim)
B = sum(..., 'double')
B = sum(..., dim,'double')
B = sum(..., 'native')
B = sum(..., dim,'native')

Description
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 
Syntax

c = a.*b
c = times(a,b)

Description
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
Syntax

K = logical(A)

Description
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.
e.g.

>> 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
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

生活在西班牙

自己动手丰衣足食

BlueAsteroid

Just another WordPress.com site

Jing's Blog

Just another WordPress.com site

Start from here......

我的心情魔方

天才遠私廚

希望能做一個分享各種資訊的好地方

语义噪声

西瓜大丸子汤的博客

笑对人生,傲立寰宇

Just another WordPress.com site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision

datarazzi

Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness

槑烎

1,2,∞

Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web

%d bloggers like this: