Effacer les filtres
Effacer les filtres

[Quick Question]Multiplications of all elements

1 vue (au cours des 30 derniers jours)
Xiao Tang
Xiao Tang le 18 Août 2012
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!

Réponse acceptée

per isakson
per isakson le 18 Août 2012
Yes. Try
B = prod( A )
B =
864
  6 commentaires
Oleg Komarov
Oleg Komarov le 18 Août 2012
@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 le 18 Août 2012
I see. Thanks a lot guys!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by