times

Element-wise multiplication, the function form of the .* operator.

Category: Symbolic Computations in MATLAB > Operators and Elementary Operations

Syntax

C = times(A, B)

Equivalent to A .* B.

C = times(A1, A2, ..., An)

Multiplies several arrays element by element.

Description

times(A, B) multiplies corresponding elements. A scalar is expanded to the size of the other argument, and compatible dimensions are expanded as for any element-wise operator. This differs from mtimes (the * operator), which is matrix multiplication.

With symbolic input the product is kept exact, so times(x, y) is x*y and times(sym([1 2 3]), [4 5 6]) is the sym vector [4, 10, 18].

Input arguments

A, B
Numeric, logical or symbolic arrays of compatible size.

Output arguments

C
Array of element-wise products.

Example

Numeric and symbolic products

times([1 2 3], [4 5 6])
syms x y
times(x, y)
times(sym([1 2 3]), [4 5 6])
Output
ans = 1×3

     4    10    18
ans = x*y
ans = 
[4, 10, 18]

See also

rdivide mtimes prod plus