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

MATLAB Vector Addition and Subtraction

You can add or subtract two vectors. The two operand vectors must be of the same type and have the same number of elements.

Online Examples

Use the following code to create a script file-

A = [7, 11, 15, 23, 9];
B = [2, 5, 13, 16, 20];
C = A + B;
D = A - B;
disp(C);
disp(D)

When running the file, it displays the following result-

9    16    28    39    29
5     6     2     7   -11