Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Guess age function
Replies: 1   Last Post: Jan 28, 2013 10:20 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Curious

Posts: 1,930
Registered: 12/6/04
Re: Guess age function
Posted: Jan 28, 2013 10:20 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"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>>



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.