Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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

Subtract Matrix and Cell Array Values

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 =

  2×2 cell array

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

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

  3×4 cell array

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

Introduced in R2010b

Was this topic helpful?