Main Content

gnegate

Generalized negation

Syntax

gnegate(x)

Description

gnegate(x) takes a matrix or cell array of matrices, and negates their element values.

Examples

Negate a Cell Array

This example shows how to negate a cell array:

x = {[1 2; 3 4],[1 -3; -5 2]};
y = gnegate(x);
y{1}, y{2}
ans = 2×2

    -1    -2
    -3    -4

ans = 2×2

    -1     3
     5    -2

Version History

Introduced in R2010b