How do I assign a value to a matrix and then calculate the total?