To plot the Fourier transform of a 1000 point sine wave at 200 Hz in Matlab, you can follow these steps:
main.m119 chars4 lines
Here, fs
is the sampling frequency, t
is the time vector of 0.5 seconds with a step size of 1/fs, and x
is the 1000-point sine wave at 200 Hz.
fft
function:main.m136 chars4 lines
Here, N
is the length of the signal, X
is the Fourier coefficients with normalization factor of N
, and f
is the frequency vector with values up to the Nyquist frequency.
main.m75 chars4 lines
Here, we plot the magnitude of the Fourier coefficients up to the Nyquist frequency. The 2*
factor is because the Fourier coefficients correspond to the amplitude of the sine wave, and we want to plot the magnitude of the complex coefficients.
The final code would look like this:
main.m332 chars12 lines
This will plot a single peak at 200 Hz with a magnitude of 0.5.
gistlibby LogSnag