how can i generate a random number between two float numbers

75 Ansichten (letzte 30 Tage)
user06
user06 am 12 Sep. 2018
Beantwortet: James Tursa am 12 Sep. 2018
I am trying to generate a random number between two float numbers by using
val = randi([mnval mxval],1,1)
where mxval and mnval are two float numbers. when i run the above command "First input must be a positive scalar integer value IMAX, or two integer values [IMIN IMAX] with IMIN less than or equal to IMAX." error is coming.

Akzeptierte Antwort

James Tursa
James Tursa am 12 Sep. 2018
This is one of the examples in the rand doc:
val = mnval + rand*(mxval-mnval);

Weitere Antworten (0)

Kategorien

Mehr zu Random Number Generation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by