# times, .*

Element-wise multiplication

## Syntax

• `C = A.*B` example
• `C = times(A,B)`

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

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

collapse 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` | `categorical` | `duration` | `calendarDuration`
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` | `categorical` | `duration` | `calendarDuration`
Complex Number Support: Yes