Make a program that generates a random number in the range s
Make a program that generates a random number in the range specified by the user. The user can also choose between a discrete range (integers only) and a continuous range. When the user chooses the discrete range the minimum and maximum values entered should be possible to get.
Solution
function randi() is used generate decrete random number
while
unifrnd() used to generate contineous random number
Matlab code:
min = input(\'Enter Min Ranges: \')
max= input(\'Enter Max Ranges: \')
choose=input(\'write d for decrete or c for continuous \')
if choose==\'d\'
decreteRandom= randi([min, max])
end
if choose==\'c\'
continuousRandom = unifrnd(min,max)
end
Output
example 1
Enter Min Ranges:5
Enter Max Ranges:10
write d for decrete or c for continuous d
3
example 2
Enter Min Ranges:5
Enter Max Ranges:10
write d for decrete or c for continuous c
6.3565
