Main Content

uminus, -

Description

example

C = -A negates the elements of A and stores the result in C.

C = uminus(A) is an alternative way to execute -A, but is rarely used. It enables operator overloading for classes.

Examples

collapse all

Create a 2-by-2 matrix, A.

A = [1 -3; -2 4]
A = 2×2

     1    -3
    -2     4

Negate the elements of A.

C = -A
C = 2×2

    -1     3
     2    -4

Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, or multidimensional array. If A has an integer data type, then it cannot be complex.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | datetime | duration | calendarDuration
Complex Number Support: Yes

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.

Version History

Introduced before R2006a