diff m-toolbox/test/test_ifft.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/test/test_ifft.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,63 @@
+% Test script for ao/ifft
+% 
+% L. Ferraioli 02-12-08
+% 
+% $Id: test_ifft.m,v 1.5 2009/09/21 14:10:58 luigi Exp $
+% 
+% Description:
+% 
+%   Generate odd and even sets of data, do fft with all possible options
+%   and test that ifft works correctly.
+% 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%% Get odd and even sets of data
+
+a1 = ao(plist('tsfcn', 'randn(size(t))', 'fs', 10, 'nsecs', 10));
+a2 = ao(plist('tsfcn', 'randn(size(t))', 'fs', 10, 'nsecs', 10.1));
+
+%% fft plain
+
+% do standard matlab fft - frequency range from 0 Hz to sampling frequency
+b1 = fft(a1,plist('type','plain'));
+b2 = fft(a2,plist('type','plain'));
+
+% ifft
+c1 = ifft(b1);
+c2 = ifft(b2);
+
+% compare with original data
+iplot(a1,c1, plist('LineStyles', {'-', '--'}));
+iplot(a2,c2, plist('LineStyles', {'-', '--'}));
+iplot(c1./a1,c2./a2,plist('LineStyles', {'-', '--'}))
+
+
+%% fft onesided
+
+% do one-sided fft - frequency range from 0 Hz to Nyquist frequency
+b1 = fft(a1,plist('type','one'));
+b2 = fft(a2,plist('type','one'));
+
+% ifft
+c1 = ifft(b1);
+c2 = ifft(b2);
+
+% compare with original data
+iplot(a1,c1, plist('LineStyles', {'-', '--'}));
+iplot(a2,c2, plist('LineStyles', {'-', '--'}));
+iplot(c1./a1,c2./a2,plist('LineStyles', {'-', '--'}))
+
+%% fft twosided
+
+% do two-sided fft - frequency range from -Nyquist to Nyquist
+b1 = fft(a1,plist('type','two'));
+b2 = fft(a2,plist('type','two'));
+
+% ifft
+c1 = ifft(b1);
+c2 = ifft(b2);
+
+% compare with original data
+iplot(a1,c1, plist('LineStyles', {'-', '--'}));
+iplot(a2,c2, plist('LineStyles', {'-', '--'}));
+iplot(c1./a1,c2./a2,plist('LineStyles', {'-', '--'}))