How i can insert a random integer between two numbers?

1 次查看(过去 30 天)
I have a variable and i want it to take a randome integer between numbers 2 and 101

回答(2 个)

Thomas Koelen
Thomas Koelen 2015-4-22
编辑:Thomas Koelen 2015-4-22
a=uint16(2+rand*99)

Star Strider
Star Strider 2015-4-22
The randi function is perfect for this:
rv = randi([2 101]);

类别

Help CenterFile Exchange 中查找有关 Random Number Generation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by