MATLAB Answers

Finding the product within an interval

2 views (last 30 days)
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)?

  0 Comments

Sign in to comment.

Accepted Answer

Roger Stafford
Roger Stafford on 19 Nov 2017
Edited: Roger Stafford on 19 Nov 2017
If v is your vector of random numbers, do this:
p = prod(v(v>=2.3 & v<=2.6)); % The desired product

  1 Comment

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags


Translated by