Please provide detailed coding. In a lottery the player has to select several nu
ID: 3544525 • Letter: P
Question
Please provide detailed coding.
In a lottery the player has to select several numbers out of a list. Write a MATLAB program that generates a list of n integers that are uniformly distributed between the numbers a and b. All the selected numbers on the list must be different. Use the function to generate a list of seven numbers from the numbers 1 through 59. Use the function to generate a list of eight numbers from the numbers 50 through 65. Use the function to generate a list of nine numbers from the numbers -25 through -2.Explanation / Answer
>
> x = zeros(m,n);
> N = B-A+1;
> p = zeros(1,N);
> for j = 1:m
> p(1:N) = A:B;
> for k = N:-1:N-n+1
> q = ceil(k*rand);
> x(j,N-k+1) = p(q);
> p(q:k-1) = p(q+1:k);
> end
> end
>
code for generating N random integers within a range (say A to B)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.