Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: can I use bsxfun for this?
Date: Thu, 27 Dec 2012 22:14:07 +0000 (UTC)
Organization: Procter &#38; Gamble Co
Lines: 11
Message-ID: <kbih7f$cgs$1@newscl01ah.mathworks.com>
References: <kbh320$1fp$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1356646447 12828 172.30.248.47 (27 Dec 2012 22:14:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 27 Dec 2012 22:14:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1343420
Xref: news.mathworks.com comp.soft-sys.matlab:785512

Peter:
Use 
[rows columns] = size(A);
to get the number of rows in A, then use 
B = repmat(B, [rows 1]);
to replicate B like this
b1 b2 b3
b1 b2 b3
b1 b2 b3
Then simply subtract
output = A-B;