Documentation

gsubtract

Generalized subtraction

Syntax

gsubtract(a,b)

Description

gsubtract(a,b) takes two matrices or cell arrays, and subtracts them in an element-wise manner.

Examples

This example shows how to subtract matrix and cell array values.

gsubtract([1 2 3; 4 5 6],[10;20])
ans =

    -9    -8    -7
   -16   -15   -14

gsubtract({1 2; 3 4},{1 3; 5 2})
ans = 

    [ 0]    [-1]
    [-2]    [ 2]

gsubtract({1 2 3 4},{10;20;30})
ans = 

    [ -9]    [ -8]    [ -7]    [ -6]
    [-19]    [-18]    [-17]    [-16]
    [-29]    [-28]    [-27]    [-26]

Was this topic helpful?