This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.



angle is a MATLAB® function.


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;

xlabel 'Frequency (Hz)'
ylabel '|y|'

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

phs = angle(fftshift(y));

xlabel 'Frequency (Hz)'
ylabel 'Phase / \pi'

See Also

| |

Introduced before R2006a

Was this topic helpful?