Subtract

Subtracts two variables. It returns the difference of x and y. It is performed element-wise if the arguments are vectors, matrices or signals. Inputs must be of the same size and the same type unless the second variable is a scalar.

Syntax

x-y

Types
 Variable NameValue TypeVariable Type
Arguments:xreal, complexscalar, vector, matrix, signal, xy-data
yreal, complexscalar, vector, matrix, signal, xy-data
Result: zreal, complex scalar, vector, matrix, signal, xy-data
Calculator Input

Use the - button to complete the operation.

Examples

Subtract Scalar from Scalar

IDDescriptionTypeValueExpression
xArgumentREAL22
yArgumentREAL33
z Result REAL -1x-y

Subtract Scalar from Vector

IDDescriptionTypeValueExpression
xArgumentREAL VECTOR

[2, 2.5]
yArgumentREAL33
z Result REAL VECTOR

x-y

Subtract Vector from Vector (Same Size)

IDDescriptionTypeValueExpression
xArgumentREAL VECTOR

[2, 2.5]
yArgumentREAL VECTOR

[3, 3.5]
z Result REAL VECTOR

x-y

Subtract Scalar from Matrix

IDDescriptionTypeValueExpression
xArgumentREAL MATRIX

[[2, 2.5, 3],[3.5, 4, 4.5]]
yArgumentREAL11
z Result REAL MATRIX

x-y

Subtract Matrix from Matrix (Same Size)

IDDescriptionTypeValueExpression
xArgumentREAL MATRIX

[[2, 2.5],[1, 1]]
yArgumentREAL MATRIX

[[1, 1],[3, 3.5]]
zResult REAL MATRIX

x-y

Subtract Scalar from Signal

IDDescriptionTypeValueExpression
xArgumentREAL SIGNAL   signal([0, 0.5, 1],[1, 2, 3])
yArgumentREAL11
z Result REAL SIGNAL   x-y

Subtract Signal from Signal (Same Size)

IDDescriptionTypeValueExpression
xArgumentREAL SIGNAL   signal([0, 0.5, 1],[1, 2, 3])
yArgumentREAL SIGNAL   signal([0, 0.5, 1],[2, 3, 4])
z Result REAL SIGNAL   x-y

Subtract Signal from Signal (Different Size)

IDDescriptionTypeValueExpression
xArgumentREAL SIGNAL   signal([0, 0.5, 1],[1, 2, 3])
yArgumentREAL SIGNAL   signal([0, 0.25, 0.5, 1],[2, 3, 4, 5])
z Result REAL SIGNAL   x-y

If the axes of abscissae are different, the signal is interpolated to the additional abscissa values by linear interpolation.