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.

abs

Absolute value (magnitude)

Description

abs is a MATLAB® function.

Examples

collapse all

Generate a signal composed of two sinusoids sampled at 100 Hz. Specify the sinusoid frequencies as 15 and 40 Hz. Compute the DFT of the sequence.

t = (0:99)/100;                        % Time vector
x = sin(2*pi*15*t) + sin(2*pi*40*t);   % Signal
y = fft(x);                            % DFT of x
m = abs(y);                            % Magnitude

Plot the magnitude of the DFT.

f = 0:50;                              % Frequency vector
m = m(1:51);                           % Unique magnitudes
stem(f,m)
ylabel 'DFT magnitude'
xlabel 'Frequency (Hz)'

Introduced before R2006a

Was this topic helpful?