How to calculate random number between Inf and 10 ?
7 views (last 30 days)
Show older comments
Suppose i have a matrix given below
A= [-Inf 52.17 54 55.82 Inf]
Now how to calculate a random number between A(1) & A(2) and the random number should be a value, not Inf
Can anyone please help me with this
0 Comments
Answers (1)
Ameer Hamza
on 18 Oct 2020
Edited: Ameer Hamza
on 18 Oct 2020
The most negative value representable in double datatype is given by -realmax. You can do something like this
A= [-Inf 52.17 54 55.82 Inf];
x = rand();
y = x*(-realmax) + A(2);
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!