Calculating Certain Fields in Matrix