Finding the product within an interval

조회 수: 1 (최근 30일)
Noah Kebschull
Noah Kebschull 2017년 11월 19일
댓글: Noah Kebschull 2017년 11월 19일
I have 250 element row vector of random numbers between intervals (-4.5, 5.5). Once I create that vector, how would I find the product of all elements between intervals (2.3, 2.6)?

채택된 답변

Roger Stafford
Roger Stafford 2017년 11월 19일
편집: Roger Stafford 2017년 11월 19일
If v is your vector of random numbers, do this:
p = prod(v(v>=2.3 & v<=2.6)); % The desired product

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by