MATLAB: [Quick Question]Multiplications of all elements

multiplication

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!

Best Answer

  • Yes. Try
    B = prod( A )
    B =
    864