Financial Toolbox | ![]() ![]() |
Adding and Subtracting Matrices
Matrix addition and subtraction operate element-by-element. The two input matrices must have the same dimensions. The result is a new matrix of the same dimensions where each element is the sum or difference of each corresponding input element. For example, consider combining portfolios of different quantities of the same stocks ("shares of stocks A, B, and C [the rows] in portfolios P and Q [the columns] plus shares of A, B, and C in portfolios R and S").
Portfolios_PQ = [100 200 500 400 300 150]; Portfolios_RS = [175 125 200 200 100 500]; NewPortfolios = Portfolios_PQ + Portfolios_RS NewPortfolios = 275.00 325.00 700.00 600.00 400.00 650.00
Adding or subtracting a scalar and a matrix is allowed and also operates element-by-element.
![]() | Matrix Algebra Refresher | Multiplying Matrices | ![]() |