Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Random number generator between two numbers - MatLab

Tags:

random

matlab

I am trying to create a random number generator between two numbers in MatLab but I am unable to figure out the correct equation.

I know that you can use the rand() function to create random numbers but what if I wanted to have numbers only generated between -.5 and .5? Is this possible to accomplish in MatLab?

like image 510
user081608 Avatar asked Feb 14 '26 14:02

user081608


1 Answers

The answer for adjusting the interval is listed in the help section on rand() :

Example 1

Generate values from the uniform distribution on the interval [a, b]: r = a + (b-a).*rand(100,1);

like image 130
Jonathan Holland Avatar answered Feb 17 '26 12:02

Jonathan Holland



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!