入门客AI创业平台(我带你入门,你带我飞行)
博文笔记

Prod 函数

创建时间:2015-07-26 投稿人: 浏览次数:459

Prod 函数

Product of array elements

矩阵元素乘积

Syntax

语法

B = prod(A)

B = prod(A,dim)

Description

描述

B = prod(A) returns the products along different dimensions of an array.

B=prod(A)返回的积值形式要依据阵列的不同规模。

If A is a vector, prod(A) returns the product of the elements.

如果A是一个向量,prod(A)返回各元素的积。

If A is a matrix, prod(A) treats the columns of A as vectors, returning a row vector of the products of each column.

如果A是一个矩阵,prod(A)将A矩阵的列如同向量一般处理,返回一个行向量形式的积值。

If A is a multidimensional array, prod(A) treats the values along the first non-singleton dimension as vectors, returning an array of row vectors. 

如果A是一个,prod(A)处理的值依据第一个non-singleton 维度作为向量,返回一个列向量阵列

B = prod(A,dim) takes the products along the dimension of A specified by scalar dim.

B=prod(A,dim),依据给定的dim值,求解A矩阵的积。

当dim值为1时,B结果为A矩阵的各列元素的积,以行向量形式表达结果;

当dim值为2时,B结果为A矩阵的各行元素的积,以列向量形式表达结果;

当dim值为3(或)时,B结果为A矩阵的原型,不做任何运算。

Examples

例如:

The magic square of order 3 is

Magic square矩阵的命令值为3得到: 

M = magic(3)

M = 

    8    1    6

    3    5    7

4    9    2 

The product of the elements in each column is 

各列上元素的积通过如下命令便可获得:

prod(M) =

 

96    45    84 

The product of the elements in each row can be obtained by:

在各行上的元素的积同样能够得到,通过如下形式的命令:

prod(M,2) = 

     48

    105

     72

声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。