Finding the product within an interval

1 Ansicht (letzte 30 Tage)
Noah Kebschull
Noah Kebschull am 19 Nov. 2017
Kommentiert: Noah Kebschull am 19 Nov. 2017
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)?

Akzeptierte Antwort

Roger Stafford
Roger Stafford am 19 Nov. 2017
Bearbeitet: Roger Stafford am 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

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by