English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Addition and Subtraction of MATLAB Matrices

You can add or subtract matrices. Both operand matrices must have the same number of rows and columns.

Online Examples

Create a script file using the following code-

a = [ 1 2 3  4 5 6 7 8 9
b = [ 7 5 6  2 0 8 5 7 1
c = a + b
d = a - b

When running the file, it displays the following result:

c =
      8     7     9
      6     5    14
      12    15    10
d =
      -6    -3    -3
      2     5    -2
      2     1     8