Skip to content

Instantly share code, notes, and snippets.

@sushruth
Last active September 13, 2016 18:33
Show Gist options
  • Save sushruth/96e4840ed62d7a816a719ef24861ccb1 to your computer and use it in GitHub Desktop.
Save sushruth/96e4840ed62d7a816a719ef24861ccb1 to your computer and use it in GitHub Desktop.

Everything is case sensitive :

N = 1000; % size of the array
fs = 8000;

noise = randn(1,N);

Fnoise = fft(noise);

f = (0:N-1)*fs/N;

plot(f, abs(Fnoise));

For flat FFT :

N = 1000; % size of the array
M = 100;  % number of FFTs to loop. Vary this value and run again to see changes in the plot.
fs = 8000;

f = (0:N-1)*fs/N; % frequency 

Fnoise = zeros(1,N);  % Initialize an array

for i = 1:M
  noise = randn(1,N);
  Fnoise = Fnoise + fft(noise);
end

Fnoise = Fnoise / M;

plot(f, abs(Fnoise));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment