From: ImageAnalyst <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: User Entry if and statement
Date: Thu, 17 Apr 2008 19:53:45 -0700 (PDT)
Lines: 31
Message-ID: <>
References: <fu8pqq$bcu$>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: 1208487225 17648 (18 Apr 2008 02:53:45 GMT)
NNTP-Posting-Date: Fri, 18 Apr 2008 02:53:45 +0000 (UTC)
Injection-Info:; posting-host=; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 
Xref: comp.soft-sys.matlab:463786

On Apr 17, 8:26=A0pm, "Ender " <> wrote:
> I am writing code that is going to ask a question than do
> certain routines after the user inputs an answer for the
> first question.
> user_entry =3D input('i or e? =A0 =A0 ','s'); =A0 % ask for user
> input asking which function do you want to solve for
> if 'i';
> =A0 =A0 disp('cool');
> elseif 'e';
> =A0 =A0 disp('ok');
> else disp('Please try again')
> end
> The display was just for testin purposes, but no matter
> what I type in for the response to the user_entry
> statement. MATLAB always displays 'cool'. MATLAB says that
> I have a character string variable for whatever letter I
> respond to the first question with, but then MATLAB always
> responds with 'cool' instead of performing the function of
> the if and statement.
> -Ender-

Sure, because 'i' is non-zero, when converted to a logical.  Try using
the strcmpi() function to compare your results to 'i' or 'e' strings.