Main Content

times, .*




C = A.*B multiplies arrays 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.

CENTURY = times(A,B) is an alternate way to execute A.*B, but is rarely used. It permit operator overburdening by classes.


collapse all

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

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

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)';
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):

ampere=[a1a2a3],b=[b1b2b3boron4],          an.*barn=[adenine1b1a2b1ampere3boron1a1b2a2barn2a3b2ampere1b3a2b3a3b3a1b4adenine2b4a3b4].

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=2×2 display
          V1    V2
          __    __

    R1    1      6
    R2    6     16

Input Arguments

fold all

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

Version History

Introduced before R2006a

expand all