Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!a23g2000hsc.googlegroups.com!not-for-mail
From: ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: User Entry if and statement
Date: Thu, 17 Apr 2008 19:53:45 -0700 (PDT)
Organization: http://groups.google.com
Lines: 31
Message-ID: <5e1093e8-63bd-41a1-9d9b-a40fbfd3990e@a23g2000hsc.googlegroups.com>
References: <fu8pqq$bcu$1@fred.mathworks.com>
NNTP-Posting-Host: 75.186.67.199
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1208487225 17648 127.0.0.1 (18 Apr 2008 02:53:45 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 18 Apr 2008 02:53:45 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: a23g2000hsc.googlegroups.com; posting-host=75.186.67.199; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 
Xref: news.mathworks.com comp.soft-sys.matlab:463786


On Apr 17, 8:26=A0pm, "Ender " <jr...@msstate.edu> 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-

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.
Regards,
ImageAnalyst