Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

라이선스가 부여된 사용자만 번역 문서를 볼 수 있습니다. 번역 문서를 보려면 로그인하십시오.

times, .*

Element-wise multiplication

Syntax

Description

example

C = A.*B multiplies arrays A and B element by element and returns the result in C.

C = times(A,B) is an alternate way to execute A.*B, but is rarely used. It enables operator overloading for classes.

Examples

collapse all

Create two vectors, A and B, and multiply them element by element.

A = [1 0 3];
B = [2 3 7];
C = A.*B
C =

     2     0    21

Create two 3-by-3 arrays, A and B, and multiply them element by element.

A = [1 0 3; 5 3 8; 2 4 6];
B = [2 3 7; 9 1 5; 8 8 3];
C = A.*B
C =

     2     0    21
    45     3    40
    16    32    18

Create a row vector a and a column vector b, then multiply them. The 1-by-3 row vector and 6-by-1 column vector combine to produce a 6-by-3 matrix with all combinations of elements multiplied.

a = [1 2 3]
a =

     1     2     3

b = (1:6)'
b =

     1
     2
     3
     4
     5
     6

a.*b
ans =

     1     2     3
     2     4     6
     3     6     9
     4     8    12
     5    10    15
     6    12    18

Related Examples

Input Arguments

collapse all

Left array, specified as a scalar, vector, matrix, or multidimensional array. Numeric inputs A and B must either be the same size or have sizes that are compatible (for example, A is an M-by-N matrix and B is a scalar or 1-by-N row vector). For more information, see Compatible Array Sizes for Basic Operations.

If A and B are datetime, duration, or calendar duration arrays, then they must be the same size unless one is a scalar.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | categorical | duration | calendarDuration
Complex Number Support: Yes

Right array, specified as a scalar, vector, matrix, or multidimensional array. Numeric inputs A and B must either be the same size or have sizes that are compatible (for example, A is an M-by-N matrix and B is a scalar or 1-by-N row vector). For more information, see Compatible Array Sizes for Basic Operations.

If A and B are datetime, duration, or calendar duration arrays, then they must be the same size unless one is a scalar.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | categorical | duration | calendarDuration
Complex Number Support: Yes

More About

collapse all

Tall Array Support

This function fully supports tall arrays. For more information, see Tall Arrays.

See Also

Introduced before R2006a

Was this topic helpful?