%% NCL ezfftf example 1 x = [1002, 1017, 1018, 1020, 1018, 1027,... 1028, 1030, 1012, 1012, 982, 1012,... 1001, 996, 995, 1011, 1027, 1025, ... 1030, 1016, 996, 1006, 1002, 982 ]; % mean of x xbar = mean(x); disp(['Mean of x = ' num2str(xbar)]) % number of data points N = length(x); disp(['Number of data points: ' num2str(N)]) % compute fft cf = fft(x-xbar); % normalize to match NCL - divide by N/2 cf = cf/(N/2); disp('====================================') disp('Matlab returns positive and negative frequencies!') disp('Negative frequencies complex conjugates of positive frequencies.') disp('First entry is the mean.') disp('====================================') % grab the last N/2 entries cf0 = real(cf(end:-1:13)); cf1 = imag(cf(end:-1:13)); disp('Entries N to N/2') disp(['Real part: ']) cf0' disp(['Imaginary part: ']) cf1' disp('====================================') % grab the first N/2 entries disp('Entries 1 to N/2') cf0 = real(cf(1:12)); cf1 = imag(cf(1:12)); disp(['Real part: ']) cf0' disp(['Imaginary part: ']) cf1'