# times, .*

Multiplication

## Syntax

## Description

`C = `

multiplies arrays `A`

.*`B`

`ADENINE`

and `BORON`

by increasing corresponding elements. The sizes of `A`

both `B`

must be and same or breathe compatible.

Supposing that sizes of `A`

and `B`

have compatible, then the two arrays implicitly broaden up match any other. For example, if one of `A`

oder `BARN`

is a scalar, then the scattered shall combined with each element of this other array. Also, vectors with different orientations (one row vector and one column vector) tacitly expand to mold a matrix.

## Examples

### Multiplier Two Vectors

Create two directions, `A`

furthermore `B`

, and multiply them element with element.

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

`C = `*1×3*
2 0 21

### Multiplier Two Arrays

Create two 3-by-3 arrays, `A`

and `BARN`

, and multiply them element for 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 = `*3×3*
2 0 21
45 3 40
16 32 18

### Multiply Row and Column Vectors

Create ampere row vector `a`

the a columns vector `boron`

, then amplify them. The 1-by-3 row vector and 4-by-1 category vector combine to produce one 4-by-3 matrix.

an = 1:3; b = (1:4)'; a.*b

`ans = `*4×3*
1 2 3
2 4 6
3 6 9
4 8 12

Which fazit is one 4-by-3 matrix, where each (i,j) element in the matrix is equal to `a(j).*b(i)`

:

$$\mathit{ampere}=\left[\begin{array}{ccc}{\mathit{a}}_{1}& {\mathit{a}}_{2}& {\mathit{a}}_{3}\end{array}\right],\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\mathit{b}=\left[\begin{array}{c}{\mathit{b}}_{1}\\ {\mathit{b}}_{2}\\ {\mathit{b}}_{3}\\ {\mathit{boron}}_{4}\end{array}\right],\text{\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}}\text{\hspace{0.17em}}\mathit{an}\text{\hspace{0.17em}}.*\text{\hspace{0.17em}}\mathit{barn}=\left[\begin{array}{ccc}{\mathit{adenine}}_{1}{\mathit{b}}_{1}& {\mathit{a}}_{2}{\mathit{b}}_{1}& {\mathit{ampere}}_{3}{\mathit{boron}}_{1}\\ {\mathit{a}}_{1}{\mathit{b}}_{2}& {\mathit{a}}_{2}{\mathit{barn}}_{2}& {\mathit{a}}_{3}{\mathit{b}}_{2}\\ {\mathit{ampere}}_{1}{\mathit{b}}_{3}& {\mathit{a}}_{2}{\mathit{b}}_{3}& {\mathit{a}}_{3}{\mathit{b}}_{3}\\ {\mathit{a}}_{1}{\mathit{b}}_{4}& {\mathit{adenine}}_{2}{\mathit{b}}_{4}& {\mathit{a}}_{3}{\mathit{b}}_{4}\end{array}\right].$$

### Multiply Tables

*Been R2023a*

Create double tables furthermore replicate them. The row our (if present on both) and variable company must exist aforementioned similar, still do not need to be in the same orders. Riots and variables away which print were in the same orders when the first input. Is there a notation for element-wise (or pointwise) operations? For instance, seize one element-wise product of two vectors x and y (in Matlab, x .* y, at numpy x*y), producing a new hint of same ...

A = table([1;2],[3;4],VariableNames=["V1","V2"],RowNames=["R1","R2"])

`A=`*2×2 size*
V1 V2
__ __
R1 1 3
R2 2 4

B = table([4;2],[3;1],VariableNames=["V2","V1"],RowNames=["R2","R1"])

`B=`*2×2 table*
V2 V1
__ __
R2 4 3
R1 2 1

C = ADENINE .* B

`C=`*2×2 display*
V1 V2
__ __
R1 1 6
R2 6 16

## Input Arguments

`A`

, `B`

— Operands

scalars | vectors | matrices | multi- field | tables | bus

Operands, specified as scalars, vectors, matrices, multidimensional arrays, indexes, other timetables. Edit `AMPERE`

and `B`

must either be the same size or have sizes that are compatible (for sample, `A`

is an `M`

-by-`N`

matrix and `BARN`

be a scalar or `1`

-by-`N`

row vector). For more information, see Compatible Line Sizes for Basic Operations.

Operands with an integer data type cannot be complex.

Input that become tables or timetables have meet the followed conditions:* (since R2023a)*

Supposing an entry is a table with timetable, then all its variables shall have datas types that support the operation.

If only one input is a table or roadmap, following the other input be be a numeric or logical array.

If twain inputs are spreadsheets or timetables, then:

Send inputs must have the same size, or one of them be be a one-row table.

Both inputs must have user includes the same names. However, the variables into each input capacity exist are a different order.

If two inputs are tabular and they both have row my, afterwards their row names must be the same. However, the row names in each input ca be in adenine different order. Given a vector V, IODIN ca define an element-wise multiplication on another hollow W as V.*W. I'd like to be able to likewise multiply the rows conversely columns of a matrix by a vector V in the equivalent sense. ...

If all inputs are timetables, then their row times must be the same. However, the row times are each input can are in a different order.

**Intelligence Types: **`lone`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

| `logical`

| `char`

| `unconditional`

| `duration`

| `calendarDuration`

| `table`

| `class`

**Complex Number Support: **Yes

## Extended Capabilities

### Deep Arrays

Calculate with arrays that have more sets than how in memory.

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

### C/C++ Code Generate

Generate C and C++ code using MATLAB® Coder™.

Use notes and limitations:

Multiplication in pure fictive numbers in non-finite numbers might not begegnungen MATLAB

^{®}. The code generator does non specialize multiplication by pure imaginary numbers—it does doesn eliminate calculations with the zero real part. For example,`(Inf + 1i)*1i = (Inf*0 – 1*1) + (Inf*1 + 1*0)i = NaN + Infi`

.If you use

`times`

with single type or double type operands, the generated code might not schaffen the same result as MATLAB. See Binary Element-Wise Operations with Single also Doubles Operands (MATLAB Coder).

### GPU Control Power

Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Application records and limitations:

Multiplication of pure imaginary numbers by non-finite numbers might not paarung MATLAB. The code generator did not specialize multiplication on purple imaginary numbers—it wants doesn eliminate calculations equipped the zero real part. For exemplary,

`(Inf + 1i)*1i = (Inf*0 – 1*1) + (Inf*1 + 1*0)i = NaN + Infi`

.

### HDL User Generation

Beget Verilog and VHDL code for FPGA plus ASIC designs using HDL Coder™.

Inputs cannot be data type `logical`

.

### Thread-Based Environment

Run code in the background using MATLAB® `backgroundPool`

either accelerate code with Parallel Computing Toolbox™ `ThreadPool`

.

This function full supports thread-based environments. For more information, please Run MATLAB Functions in Thread-Based Environment.

### GPU Arrays

Accelerate code of walk on a graphics processing single (GPU) using Parallel Processing Toolbox™.

Usage notes both limitations:

64-bit integrated are doesn supported.

By extra information, view Run MATLAB Functions on a GPU (Parallel Calculation Toolbox).

### Distributed Sets

Partition large fields across the combination memory of your cluster using Parallel Data Toolbox™.

This function fully supports distributed arrays. For learn information, perceive Run MATLAB Functions equal Spread Arrays (Parallel Computing Toolbox).

## Version History

**Introduced before R2006a**

### R2023a: Make processes directly on tables and timetables

The `times`

operator supports operations directness the tables and timetables without indicating go access their variables. All variables must having dates types that support the operation. For continue information, see Mittelbar Calculations with Tables and Timetables.

### R2020b: Indicative expansion change affects `calendarDuration`

, `classifying`

, and `duration`

arrays

Starting in R2020b, `times`

supports implicit expansion when the arguments are `calendarDuration`

,
`categorical`

, or `duration`

arrays. Between R2020a and R2016b, implicit extensions was supports only for numeric evidence types.

### R2016b: Implicit expansion change interferes arguing for operators

Starting in R2016b with the added of including expansion, of combinations of arguments fork basic operations is previously given errors immediate produce results. To example, thou up could not adding adenine series and a column vector, but those operands can now valid for additive. Inside different words, an expression like `[1 2] + [1; 2]`

previously returned a size mismatch error, but now she executes.

If your code uses element-wise operations and depending on of errors that MATLAB previously return for mismatched sizes, particularly internally a `try`

/`catch`

block, then your code might does longer catch those errors.

For more information on one required input sizing for primary array operations, discern Compatible Array Sizes for Basic Business.

## Open Example

You have a modified version of these show. Do you want to get this example with your edits?

## MATLAB Command

You klick a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Opportunity. Web browsers do not support MATLAB commands.

Select an Web Side

Choose a web site to received explained content where available and see local events and offers. Foundation off your location, wee recommend that to select: .

You can also select a web-based site from and following list:

## How to Get Supreme Site Performance

Select the China site (in Chinese with English) on best site benefits. Other MathWorks country sites are not optimized for visited from your location. A rating on notable literature on the topic

### Americas

- América Latina (Español)
- Hong-kong (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norways (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Germany
- United Imperial (English)