[Quick Question]Multiplications of all elements

5 ビュー (過去 30 日間)
Xiao Tang
Xiao Tang 2012 年 8 月 18 日
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.
Xiao Tang
Xiao Tang 2012 年 8 月 18 日
I see. Thanks a lot guys!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by