diff dsp/realfft.m @ 32:c3b0cd708782

Imported core dsp tools.
author samer
date Sun, 20 Jan 2013 13:48:47 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dsp/realfft.m	Sun Jan 20 13:48:47 2013 +0000
@@ -0,0 +1,18 @@
+function [y,f] = realfft(x,nfft)
+% realfft - Do FFT assuming real data, returning complex half spectrum
+%
+% realfft ::
+%    [[L,T]->real]     ~'sequence of T L-point frames',
+%    N:natural         ~'FFT size'
+% -> [[M,T]->complex]  ~'sequence of T M-point complex spectra',
+%    [[M]]             ~'normalised centre frequency for each bin'.
+%      
+% Note that M=dftbins(N).
+
+% apply the window and do FFT on each column, then
+% assume it's a real signal and discard half the bins
+y = fft(x,nfft);
+select=1:dftbins(nfft);
+y = y(select,:);
+% compute the normalised frequency for each bin
+f=(select-1)/nfft;