Absolute value (magnitude)


abs is a MATLAB® function.


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
ylabel 'DFT magnitude'
xlabel 'Frequency (Hz)'

Was this topic helpful?