Documentation Center

  • Trial Software
  • Product Updates

abs

Absolute value (magnitude)

Description

abs is a MATLAB® function.

Examples

expand all

Magnitude of the DFT of a Sequence

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)'

Was this topic helpful?