comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % Test script for ao/ifft
2 %
3 % L. Ferraioli 02-12-08
4 %
5 % $Id: test_ifft.m,v 1.5 2009/09/21 14:10:58 luigi Exp $
6 %
7 % Description:
8 %
9 % Generate odd and even sets of data, do fft with all possible options
10 % and test that ifft works correctly.
11 %
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13
14 %% Get odd and even sets of data
15
16 a1 = ao(plist('tsfcn', 'randn(size(t))', 'fs', 10, 'nsecs', 10));
17 a2 = ao(plist('tsfcn', 'randn(size(t))', 'fs', 10, 'nsecs', 10.1));
18
19 %% fft plain
20
21 % do standard matlab fft - frequency range from 0 Hz to sampling frequency
22 b1 = fft(a1,plist('type','plain'));
23 b2 = fft(a2,plist('type','plain'));
24
25 % ifft
26 c1 = ifft(b1);
27 c2 = ifft(b2);
28
29 % compare with original data
30 iplot(a1,c1, plist('LineStyles', {'-', '--'}));
31 iplot(a2,c2, plist('LineStyles', {'-', '--'}));
32 iplot(c1./a1,c2./a2,plist('LineStyles', {'-', '--'}))
33
34
35 %% fft onesided
36
37 % do one-sided fft - frequency range from 0 Hz to Nyquist frequency
38 b1 = fft(a1,plist('type','one'));
39 b2 = fft(a2,plist('type','one'));
40
41 % ifft
42 c1 = ifft(b1);
43 c2 = ifft(b2);
44
45 % compare with original data
46 iplot(a1,c1, plist('LineStyles', {'-', '--'}));
47 iplot(a2,c2, plist('LineStyles', {'-', '--'}));
48 iplot(c1./a1,c2./a2,plist('LineStyles', {'-', '--'}))
49
50 %% fft twosided
51
52 % do two-sided fft - frequency range from -Nyquist to Nyquist
53 b1 = fft(a1,plist('type','two'));
54 b2 = fft(a2,plist('type','two'));
55
56 % ifft
57 c1 = ifft(b1);
58 c2 = ifft(b2);
59
60 % compare with original data
61 iplot(a1,c1, plist('LineStyles', {'-', '--'}));
62 iplot(a2,c2, plist('LineStyles', {'-', '--'}));
63 iplot(c1./a1,c2./a2,plist('LineStyles', {'-', '--'}))