Date: Jan 28, 2013 10:20 AM
Author: Curious
Subject: Re: Guess age function

"Chan Khoa" wrote in message <ke63ns$d3t$1@newscl01ah.mathworks.com>...
> I'm new to MatLab and stuck at this problem can anyone one help?
>
> Write the function guessAge(range) where range is the range which the exact age is in. This
> function can only ask the user Yes/No questions and receive the answer from the user. Using
> the answer, the function continues to ask if it cannot guess the age correctly. Otherwise, the
> function displays and returns the guessed age.
> Requirements: the function cannot ask all numbers in the given range. It needs to minimize the
> number of questions asked.


Try adapting the Bisection Method:

<<http://en.wikipedia.org/wiki/Bisection_method>>

If you are having problems coding this in MATLAB, try reading the "Getting Starting" guide that comes with MATLAB (or is available online at MathWorks). It is a quick read and (with the examplkes) should answer most of your questions.

<<http://www.mathworks.com/help/matlab/getting-started-with-matlab.html>>