I am looking to generate random numbers between a certain set of decimal numbers (for eg: 0.3 to 0.4). I tried using rand command but if anyone has a workaround?

 채택된 답변

Voss
Voss 2022년 5월 31일

0 개 추천

rand gives you number(s) between 0 and 1, so with appropriate scaling and offsetting, you can use it to get number(s) from any given range:
data = 0.3 + 0.1*rand(1,100) % 100 numbers between 0.3 and 0.4
data = 1×100
0.3596 0.3187 0.3503 0.3990 0.3179 0.3482 0.3384 0.3025 0.3906 0.3738 0.3543 0.3069 0.3705 0.3117 0.3616 0.3272 0.3565 0.3828 0.3806 0.3173 0.3632 0.3188 0.3767 0.3447 0.3255 0.3521 0.3875 0.3934 0.3428 0.3297
plot(data)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2022년 5월 31일

답변:

2022년 5월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by