Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Skipped if statements
Date: Thu, 29 Oct 2009 10:07:01 +0000 (UTC)
Organization: Forschungszentrum J&#252;lich GmbH
Lines: 31
Message-ID: <hcbpg5$6nb$1@fred.mathworks.com>
References: <hcb1qm$958$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 1256810821 6891 172.30.248.37 (29 Oct 2009 10:07:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 29 Oct 2009 10:07:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1088664
Xref: news.mathworks.com comp.soft-sys.matlab:580891


"Jason Mickey" <jmick175@gmail.com> wrote in message <hcb1qm$958$1@fred.mathworks.com>...
> Why is my if statement being skipped? (The test if t==2 fails, even though the final value of t is 2). I have in a while loop
> 
> if (t==2.0000) || (t==0.2) || (t==0.8) || (t==1.0) || (t==2.0)
>         figure
>         contour(X,Y,Tnew);
> end
> 
> 
> Also, is there a way to title my figure with the value of t encoded in it? I tried
> 
> title('t = %1.3f',t)
> 
> But that didn't work.
> 
> 
> Thanks.

Hi Jason

numbers are not exact for reason of binarisation, they might have a small deviation so try

abs(t-2.0) < alloweddeviation 

instead of

t==2.0

hth

kinor