how can i generate a random number between two float numbers

조회 수: 108 (최근 30일)
user06
user06 2018년 9월 12일
답변: James Tursa 2018년 9월 12일
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.

채택된 답변

James Tursa
James Tursa 2018년 9월 12일
This is one of the examples in the rand doc:
val = mnval + rand*(mxval-mnval);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Adding custom doc에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by