필터 지우기
필터 지우기

[Quick Question]Multiplications of all elements

조회 수: 1 (최근 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개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by