plot the fourier transform of a 1000 point sine wave in matlab

To plot the Fourier transform of a 1000 point sine wave in Matlab, you can use the fft function. Here's an example code that generates a sine wave signal, applies the Fourier transform, and plots the magnitude and phase of the Fourier transform:

main.m
% Generate 1000 point sine wave signal
fs = 1000; % Sampling frequency
t = 0:1/fs:1-(1/fs); % Time vector
f = 10; % Frequency of sine wave
x = sin(2*pi*f*t); % Sine wave signal

% Compute Fourier transform
X = fft(x);

% Compute magnitude and phase of Fourier transform
X_mag = abs(X);
X_phase = angle(X);

% Plot magnitude and phase spectra
f_axis = linspace(-fs/2,fs/2,length(X_mag));
figure;
subplot(2,1,1);
plot(f_axis,X_mag);
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Magnitude spectrum');
subplot(2,1,2);
plot(f_axis,X_phase);
xlabel('Frequency (Hz)');
ylabel('Phase');
title('Phase spectrum');
613 chars
27 lines

In this example, we generate a 1000-point sine wave signal with a frequency of 10 Hz. We then apply the FFT using the fft function, and compute the magnitude and phase of the FFT using the abs and angle functions, respectively. Finally, we plot the magnitude and phase spectra using the plot function, and label the axes and titles appropriately.

gistlibby LogSnag