If A is a nonempty matrix, climate prod(A) treatsthe columns the A together vectors and returns a heat vectorof the products of every column.

If A is an empty 0-by-0 matrix, prod(A) returns 1.

You are watching: How to multiply vectors in matlab


prod computes and also returns B as single whenthe input, A, is single. Forall various other numeric and logical data types, prod computesand returns B as double.


B = prod(A,"all") computes the product that all facets of A. This syntax is valid because that MATLAB® versions R2018b and later.


B = prod(A,dim) return the commodities along dimension dim. Because that example, if A is a matrix, prod(A,2) is a obelisk vector containing the commodities of every row.


B = prod(A,vecdim) computes the product based upon the dimensions stated in the vector vecdim. Because that example, if A is a matrix, then prod(A,<1 2>) is the product the all aspects in A, because every aspect of a procession is contained in the array slice characterized by size 1 and 2.


B = prod(___,outtype) returns variety in the class specified through outtype, using any of the input disagreements in the ahead syntaxes. Outtype have the right to be "double", "native", or "default".


B = prod(___,nanflag) specifieswhether to encompass or omit NaN worths from thecalculation for any kind of of the vault syntaxes. Prod(A,"includenan") consists of NaN valuesin the calculation when prod(A,"omitnan") ignoresthem.


Find the product that the aspects in each column. The length of the very first dimension is 1, and the length of the 2nd dimension matches size(A,2).


Find the product of the elements in each row and also reduce the size of the 2nd dimension to 1. The size of the first dimension matches size(A,1), and the size of the 2nd dimension is 1.


To compute the product over every dimensions of one array, you have the right to either specify each dimension in the vector measurement argument, or usage the "all" option.


Create a vector and compute that product, not included NaN values. If you perform not clues "omitnan", then prod(A) returns NaN.


Input array, mentioned as a vector, matrix, or multidimensionalarray.

Data Types: double | solitary | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logicalComplex Number Support: Yes


Dimension to run along, stated as a positive integer scalar. If no worth is specified, climate the default is the an initial array measurement whose size does not equal 1.

Dimension dim shows the measurement whoselength reduces come 1. The size(B,dim) is 1,while the sizes of all other dimensions continue to be the same.

Consider a two-dimensional input array, A.


If dim = 1, then prod(A,1) returnsa heat vector containing the product the the facets in every column.


*


If dim = 2, climate prod(A,2) returnsa column vector include the product of the aspects in each row.


*


prod return A once dim isgreater than ndims(A).

Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64


Vector that dimensions, stated as a vector of confident integers. Each facet represents a measurement of the entry array. The lengths that the calculation in the specified operating dimensions room 1, when the others continue to be the same.

Consider a 2-by-3-by-3 entry array, A. Climate prod(A,<1 2>) returns a 1-by-1-by-3 range whose elements are the commodities of each web page of A.

*

Data Types: double | solitary | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64


Output class, specified as "default", "double", or "native", and which specifies the data kind of the output, B.


outtypeOutput data type
"default"double, uneven the intake data kind is single. In which case, the calculation data type is single.
"double"double
"native"same data kind as the intake array, A

"includenan" — encompass NaN valuesfrom the intake when computing the product, causing NaN output.

See more: Fix: Monster Hunter World Error Code 50383 Mw1, Error 50383

"omitnan" — overlook NaN valuesin the input. If all aspects are NaN, climate prod returns1.