Path: news.mathworks.com!newsfeed-00.mathworks.com!NNTP.WPI.EDU!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: if else - odd -even in Matlab
Date: Mon, 11 Aug 2008 23:10:27 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 21
Message-ID: <g7qgt3$hls$1@canopus.cc.umanitoba.ca>
References: <g7qesi$8nl$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1218496227 18108 192.70.172.160 (11 Aug 2008 23:10:27 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Mon, 11 Aug 2008 23:10:27 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:484989


In article <g7qesi$8nl$1@fred.mathworks.com>,
Marie Hadji <andry358@hotmail.com> wrote:

>Can anybody guide me how to do this right in matlab.
>Actually How I can distinguish odd from even from numbers (0
>to 8 with if and else)?

>ex. if x==1 or x==3 or x==5 or x==7 do that else if x==0 or
>x==2 or x==4 or x==6 or x==8 do that.

first = @(v) v(1);
if first(factor(x)) - 2
  %odd
else
  %even
end
-- 
  "I will speculate that [...] applications [...] could actually see a
  performance boost for most users by going dual-core [...] because it
  is running the adware and spyware that [...] are otherwise slowing
  down the single CPU that user has today"           -- Herb Sutter