Date: Nov 17, 2012 2:39 PM
Author: Daniel Gebhardt
Subject: Re: Subtract values in a matrix

"Bob Ferreira" <migmick2000@hotmail.com> schrieb am Sat, 17 Nov 2012 19:12:14 +0000 (UTC):

> I have a matrix which has "L" lines and "C" columns. I want to subtract each value in the matrix by the [...] first value in the [...] line [...]

> Example: m = [2,2,2;3,3,3;4,4,4] the matrix given should be [0,0,0;-1,-1,-1;-2,-2,-2]

Hi,

even so it might not scale well, and eventually fail on large matrices due to memory, it should work:

(diag(m(1,:))*ones(size(m))-m')'


Daniel