Documentation

### This is machine translation

Mouseover text to see original. Click the button below to return to the English version of the page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

# abs

Absolute value and complex magnitude

## Syntax

``Y = abs(X)``

## Description

example

````Y = abs(X)` returns the absolute value of each element in array `X`.If `X` is complex, `abs(X)` returns the complex magnitude.```

## Examples

collapse all

`y = abs(-5)`
```y = 5 ```

Create a numeric vector of real values.

`x = [1.3 -3.56 8.23 -5 -0.01]'`
```x = 5×1 1.3000 -3.5600 8.2300 -5.0000 -0.0100 ```

Find the absolute value of the elements of the vector.

`y = abs(x)`
```y = 5×1 1.3000 3.5600 8.2300 5.0000 0.0100 ```
`y = abs(3+4i)`
```y = 5 ```

## Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, or multidimensional array. If `X` is complex, then it must be a `single` or `double` array. The size and data type of the output array is the same as the input array.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `duration`

collapse all

### Absolute Value

The absolute value (or modulus) of a real number is the corresponding nonnegative value that disregards the sign.

For a real value, `a`, the absolute value is:

• `a`, if `a` is greater than or equal to zero

• `-a`, if `a` is less than zero

`abs(-0)` returns `0`.

### Complex Magnitude

The complex magnitude (or modulus) is the length of a vector from the origin to a complex value plotted in the complex plane.

For a complex value, $|a+bi|$ is defined as $\sqrt{{a}^{2}+{b}^{2}}$.
{"ft_lang_label":"__label__en","ft_lang_prob":0.7088873,"math_prob":0.9878405,"size":2531,"snap":"2019-13-2019-22","text_gpt3_token_len":663,"char_repetition_ratio":0.10091017,"word_repetition_ratio":0.020642202,"special_character_ratio":0.26787832,"punctuation_ratio":0.12401575,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9948979,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-03-19T10:49:19Z\",\"WARC-Record-ID\":\"<urn:uuid:24953316-39e7-4051-bf9b-743dc104eacb>\",\"Content-Length\":\"86224\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e58f9b6c-6ebb-48ae-bad9-117667b1202e>\",\"WARC-Concurrent-To\":\"<urn:uuid:78b83966-de5d-45b4-8ce7-cf7baf508677>\",\"WARC-IP-Address\":\"104.104.76.25\",\"WARC-Target-URI\":\"https://de.mathworks.com/help/matlab/ref/abs.html\",\"WARC-Payload-Digest\":\"sha1:7FHIDHSIYOWDI3HDC3AGJOYZNSTUMGBZ\",\"WARC-Block-Digest\":\"sha1:PSAOXGJ3UHSA3VDUGZVWCQWR7BHFJFWW\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-13/CC-MAIN-2019-13_segments_1552912201953.19_warc_CC-MAIN-20190319093341-20190319115341-00550.warc.gz\"}"}