Clear Filters
Clear Filters

[Quick Question]Multiplications of all elements

1 view (last 30 days)
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!

Accepted Answer

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

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!