[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!
댓글 수: 0
채택된 답변
per isakson
2012년 8월 18일
Yes. Try
B = prod( A )
B =
864
댓글 수: 6
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 Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!