% function to do fast fourier transform on the signal % Usage [k,s] = fourier(x) % % where k is index from 0 to N-l % x is the input signal % s is the power spectrum % N is the length of the series % % The spectrum is symmetrical about the middle, corresponding to negative % frequency. Use only the first half of the spectrum for the pset. function [k,s] = fourier(x) N = length(x); k = 0:N - 1; s = abs(1/sqrt(N)*fft(x)).^2; %To plot spectrum, type %>> plot(k,s);