Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Substraction between two matix with different dimension
Date: Sat, 11 May 2013 17:41:07 +0000 (UTC)
Organization: Boeing Co
Lines: 15
Message-ID: <kmlvrj$7k9$1@newscl01ah.mathworks.com>
References: <kml8bn$c49$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-01-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1368294067 7817 172.30.248.46 (11 May 2013 17:41:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 11 May 2013 17:41:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:795361

"Jamal" wrote in message <kml8bn$c49$1@newscl01ah.mathworks.com>...
> Dear all
> 
> I have 2 matix which has dimension;
> 1. (911 x 38)
> 2. (911 x 2)
> 
> Both matrix has constant values at first column.
> I would like to substract the values of the rest of the column in 1st matrix (2nd - 37th column) with the 2nd column value from the 2nd matrix.

A = rand(911,38);
B = rand(911,2);
A(:,2:38) = bsxfun(@minus,A(:,2:38),B(:,2));

James Tursa