extractResiduals function

Extract residual matrices