Path: news.mathworks.com!newsfeed-00.mathworks.com!solaris.cc.vt.edu!news.vt.edu!news.glorb.com!feeder.erje.net!newsfeed.straub-nv.de!news.mb-net.net!open-news-network.org!aioe.org!.POSTED!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Creating a vector by comparing values in two other vectors
Date: Sat, 03 Sep 2011 12:50:00 -0500
Organization: Aioe.org NNTP Server
Lines: 17
Message-ID: <j3tpcj$ije$1@speranza.aioe.org>
References: <j3torj$h6o$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: RlDXb9bXXv3vKfRLlg0yrw.user.speranza.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11
X-Notice: Filtered by postfilter v. 0.8.2
Xref: news.mathworks.com comp.soft-sys.matlab:742147

On 9/3/2011 12:41 PM, Ulrik Nash wrote:
...

> when a given value in B is larger than the corresponding value in A,
> then the corresponding value in C is -1, otherwise 1.
...

Come on, you're not even trying here... :(

W/O being clever at all,

C=ones(size(A)); C(B>A)=-1;

There are any number of ways to make it work in one step; thinking of 
one of them is left as "exercise for the student"

--