Question: Write a MATLAB function that takes in a single value. That value will be an integer between 1 and 1 million. Write a function that

 Write a MATLAB function that takes in a single value. That

Write a MATLAB function that takes in a single value. That value will be an integer between 1 and 1 million. Write a function that will repeatedly have the computer try and guess the input number, where it will only use the information about its previous guesses being too high or too low. The function should assume the number is in the interval (a,b) where initially a is 1 and bis 1 million. It should then randomly guess an integer, which I will call, in that range, and check to see if the random number is too big or too small. If it is too big, then you know that input is now between fa,b] where bat, while it it is to small the next guess should be between [a, b] where a=r. The code will continue looping until the correct number is found, after each guess changing either a or b. The function should return the input number along with the number of guesses it took the computer to find it. Function e Reset DI MATLAB Documentatio Code to call your function Reset 1 [Foundum, CNT)-randonguess (857042)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!