[Quick Question]Multiplications of all elements

1 次查看(过去 30 天)
Hi guys,
I have a matrix A = [ 1;9;1;4;4;6]
Is there any efficient way other than writing a loop that reach the result,
B = 1*9*1*4*4*6 = 864
Thanks a lot
==== Problem solved. Those comments are really useful!

采纳的回答

per isakson
per isakson 2012-8-18
Yes. Try
B = prod( A )
B =
864
  6 个评论
Oleg Komarov
Oleg Komarov 2012-8-18
@Xiao: the documentation of prod() references cumprod(). You better give a try to the documentation, since it will definitely save you time.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by