Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: function- help needed!
Date: Mon, 17 Aug 2009 11:33:01 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 26
Message-ID: <h6bf5d$mn6$1@fred.mathworks.com>
References: <h6beq6$1e1$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1250508781 23270 172.30.248.37 (17 Aug 2009 11:33:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 17 Aug 2009 11:33:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:563921

"lou lou Pengant" <bad22@bad.com> wrote in message <h6beq6$1e1$1@fred.mathworks.com>...
> Create a matlab function called birthday. The argument of the function is a , where a is a persons age. 
> 
> if a is less than 21 then the function must output a text string of the following form:
> eg, if a=7, the text string should be 'I am 7 years old'
>      if a=10, the text string should be 'I am 10 years old'
> 
> However, if a is 21 or over, the output text string should be 'I have passed my 21st birthday'
> 
> 
> I am having difficulty with creating the first part of the question, when ages are less than 21- I dont know how to make the age in the text string a variable.
> 
> function [display]=birthday(a)
> a=input('How old are you?');
> if a>=21;
>     disp('I have passed my 21st birthday')
> elseif a<21
> THIS IS THE LINE THAT I NEED HELP ON!!
> end
> end

a hint:

     help sprintf;

us