# Matlab, 58 − 3 = 55

Using an anonymous function:

 @(a,b)flipud(blkdiag(a^2*ones(a)-a*b,b^2*ones(b)-a*b)+a*b)

Example:

 >> @(a,b)flipud(blkdiag(a^2*ones(a)-a*b,b^2*ones(b)-a*b)+a*b)
 ans = 
 @(a,b)flipud(blkdiag(a^2*ones(a)-a*b,b^2*ones(b)-a*b)+a*b)
 >> ans(4,3)
 ans =
 12 12 12 12 9 9 9
 12 12 12 12 9 9 9
 12 12 12 12 9 9 9
 16 16 16 16 12 12 12
 16 16 16 16 12 12 12
 16 16 16 16 12 12 12
 16 16 16 16 12 12 12

 >> @(a,b)flipud(blkdiag(a^2*ones(a)-a*b,b^2*ones(b)-a*b)+a*b)
 ans = 
 @(a,b)flipud(blkdiag(a^2*ones(a)-a*b,b^2*ones(b)-a*b)+a*b)
 >> ans(0,3)
 ans =
 9 9 9
 9 9 9
 9 9 9

### (Old solution) 59 − 3 = 56

Using an anonymous function:

 @(a,b)[b*a*ones(b,a) b^2*ones(b);a^2*ones(a) a*b*ones(a,b)]