Prod 函数

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

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值