Last active
July 17, 2018 10:12
-
-
Save Arunprakash-A/79481937789ed132b18671c87ea0c3ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Computing FFT for Basic Signals and plot the spectra %% | |
%% Author: A Arun Prakash Mail:[email protected] %% | |
clc | |
close all; | |
%Generae sin signal of 10 Hz | |
Fs=1000; % Sampling Frequency > 2 * fmax , here fmax = 10 | |
t=0:(1/Fs):1; | |
x=sin(2*pi*10*t); | |
%%% Your COde Goes Here to plot the spectra of x %%% | |
% First compute length of input | |
L=length(x); | |
% Check whether length is in power of 2 | |
NFFT = 2^nextpow2(L) | |
% use this length to compute N-point FFT to the input | |
Y = fft(x,NFFT)/L; | |
% Plot the spectrum | |
f = Fs/2*linspace(-1,1,NFFT); | |
Y=fftshift(Y); | |
plot(f,2*abs(Y)) | |
xlabel('Frequency (Hz)') | |
ylabel('|Y(f)|') | |
%% Approx 4 lines of code %% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment