How can I generate a random number that is negative or positive and between two other values?
이전 댓글 표시
I need to write a function that generates two numbers that are between the negative and positive values of an integer. For example, if I call the function and input 7 it should generate two random numbers between -7 and +7. I can't figure out a way to use the randi function because the values I need can't be just integers.
채택된 답변
추가 답변 (2개)
Rahul Gulia
2020년 1월 22일
1 개 추천
>> randi([-2,2],3,3) will give the desired output.
Thanks for pointing out my mistake @ Walter Roberson .
Hayatullahi Adeyemo
2017년 11월 19일
0 개 추천
카테고리
도움말 센터 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!