Write a Matlab code that will allow a user to enter in a cri

Write a Matlab code that will allow a user to enter in a \"critical number\" between 0 and 1, and then track the number of times that a random number must be generated in order to be greater than the \"critical number\". Output the number of attempts that were necessary, and the numbers that were not successful. Be sure that you code is working correctly.

Solution

num = input(\'Enter a critical number(between 0 and 1): \');
attempts = 1;
guess = round(rand(1));
while(guess < num)
attempts = attempts + 1;
guess = round(rand(1));
end
attempts

 Write a Matlab code that will allow a user to enter in a \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site