# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# angle

## Description

angle is a MATLAB® function.

## Examples

collapse all

Create an arbitrary complex number. Compute its magnitude and phase.

z = 42*exp(1j*0.1234)
z =
41.6806 + 5.1697i

mag = abs(z)
mag = 42
phs = angle(z)
phs = 0.1234

Generate a signal that consists of two sinusoids of frequencies 15 Hz and 40 Hz. The signal is sampled at 100 Hz for one second.

fs = 100;
t = 0:1/fs:1-1/fs;
x = sin(2*pi*15*t) + sin(2*pi*40*t);

Compute the discrete Fourier transform of the signal. Plot the magnitude of the transform as a function of frequency.

y = fft(x);

ly = length(y);
f = (-ly/2:ly/2-1)/ly*fs;

stem(f,abs(fftshift(y)))
xlabel 'Frequency (Hz)'
ylabel '|y|'

Find the phase of the transform and plot it as a function of frequency.

phs = angle(fftshift(y));

plot(f,phs/pi)
xlabel 'Frequency (Hz)'
ylabel 'Phase / \pi'
grid