Path: news.mathworks.com!not-for-mail
From: "us " <us@neurol.unizh.ch>
Newsgroups: comp.soft-sys.matlab
Subject: Re: What's the function to compare array elements?
Date: Sun, 12 Aug 2007 10:35:22 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 17
Message-ID: <f9mnp9$jrp$1@fred.mathworks.com>
References: <f9mhuo$c8u$1@reader01.singnet.com.sg>
Reply-To: "us " <us@neurol.unizh.ch>
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 1186914922 20345 172.30.248.37 (12 Aug 2007 10:35:22 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 12 Aug 2007 10:35:22 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:423565


G Iveco:
<SNIP running out of time...

> if an element is lower than 0.5, set it to 0, above 0.5, 
set it to 1...

one of the solutions

     vr=rand(1,5);
     v=vr;
     v(v>=.5)=1;
     v(v<.5)=0;
% -or- in this particular case
%    v(v~=1)=0;
     [vr;v]

us