PXY = [7  2  8  5  4; 4  2  5  5  9; 2  4  8  5  1]/sym(71);
x = 1:3; y = 1:5;

pX = sum(PXY,2).'
eval(pX)
   
pY = sum(PXY,1)
eval(pY)

EX = pX*(x.')
eval(EX)

EY = pY*(y.')
eval(EY)

VarX = ((x-EX).^2)*pX.'
eval(VarX)

VarY = ((y-EY).^2)*pY.'
eval(VarY)