Documentation Center

  • Trial Software
  • Product Updates
我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

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

expand all

Multiply Two Vectors

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

Multiply Two Arrays

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

Input Arguments

expand all

A — Left arrayscalar | vector | matrix | multidimensional array

Left array, specified as a scalar, vector, matrix, or multidimensional array. Inputs A and B must be the same size unless one is a scalar. A scalar value expands into an array of the same size as the other input.

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

B — Right arrayscalar | vector | matrix | multidimensional array

Right array, specified as a scalar, vector, matrix, or multidimensional array. Inputs A and B must be the same size unless one is a scalar. A scalar value expands into an array of the same size as the other input.

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

See Also

Was this topic helpful?