Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.4.1 - English

Change language to:
Français - 日本語 - Português - Русский

Please note that the recommended version of Scilab is 2024.1.0. This page might be outdated.
See the recommended documentation of this function

Scilab help >> Matlab to Scilab Conversion Tips > Matlab-Scilab equivalents > P > prod (Matlab function)

prod (Matlab function)

Product of array elements

Matlab/Scilab equivalent

Matlab Scilab

Particular cases


Scilab prod(A) returns the product of all components of A. So, if A is a vector, then Scilab and Matlab work in the same way. If A is a matrix, Scilab prod(A) gives the product of all elements of A but Matlab returns the product of each column. Finally, if A is a multidimensional array, Matlab works on the first non-singleton dimension of A what Scilab does not. So, to be sure to find a Scilab equivalent for Matlab call to prod it is better to precise dimension on which to work.


In Scilab dim=1 is equivalent to dim="r" and dim=2 is equivalent to dim="c". In Matlab, dim can be greater than the number of dimension of A (in this case, M=A), in Scilab you will get an error message.


Matlab Scilab
A = [1,2,3;4,5,6]
M = prod(A)
M = [4,10,18]
M = prod(A,1)
M = [4,10,18]
A = [1,2,3;4,5,6]
M = prod(A)
M = 720
M = prod(A,"r")
M = [4,10,18]
Report an issue
<< primes (Matlab function) P Q >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Apr 02 17:36:24 CEST 2013