MATLAB: Matrix vector substraction

matrices

z=[1,2,3,4,5,6,7,8;4,5,6,7,8,9,0,1;1,2,3,4,5,6,7,8;10,11,12,13,0,0,0,0];
y=[1,2,3,4];
how can i find z-y without loops thanks.

Best Answer

M = bsxfun(@minus,z,y')
assuming you want each row of y transpose (or column of y as it is) subtracted from each row of z. Otherwise you'll have to define how you want the subtraction to works since z/y are different sizes.
Related Question