Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/ifft_core.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 % IFFT_CORE Simple core method which computes the ifft. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: Simple core method which computes the ifft. | |
5 % | |
6 % CALL: ao = ifft_core(ao, type) | |
7 % | |
8 % INPUTS: ao: Single input analysis object | |
9 % type: The ifft type | |
10 % 'symmetric' | |
11 % 'nonsymmetric' | |
12 % | |
13 % VERSION: $Id: ifft_core.m,v 1.6 2011/02/14 19:33:35 ingo Exp $ | |
14 % | |
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
16 function bs = ifft_core(bs, type) | |
17 | |
18 switch class(bs.data) | |
19 case {'fsdata'} | |
20 fs = bs.data.fs; | |
21 % check fft type | |
22 if any((bs.data.x)<0) % two sided fft | |
23 utils.helper.msg(utils.const.msg.PROC1, 'two sided fft'); | |
24 y = ifftshift(bs.data.y); | |
25 else | |
26 % get minimum frequency step | |
27 df = bs.data.x(end)-bs.data.x(end-1); | |
28 if abs(((fs-df)-bs.data.x(end)))<eps % plain fft | |
29 utils.helper.msg(utils.const.msg.PROC1, 'plain fft'); | |
30 y = bs.data.y; | |
31 elseif abs((bs.data.x(end)-fs/2))<eps % onesided fft even nfft | |
32 utils.helper.msg(utils.const.msg.PROC1, 'one sided fft even nfft'); | |
33 y1 = bs.data.y(1:end); | |
34 y2 = conj(bs.data.y(end-1:-1:2)); | |
35 if size(y1,1)==1 % raw | |
36 y = [y1 y2]; | |
37 else | |
38 y = [y1;y2]; | |
39 end | |
40 else % onesided fft odd nfft | |
41 utils.helper.msg(utils.const.msg.PROC1, 'one sided fft odd nfft'); | |
42 y1 = bs.data.y(1:end); | |
43 y2 = conj(bs.data.y(end:-1:2)); | |
44 if size(y1,1)==1 % raw | |
45 y = [y1 y2]; | |
46 else | |
47 y = [y1;y2]; | |
48 end | |
49 end | |
50 end | |
51 | |
52 y = ifft(y, type); | |
53 % Keep the data shape if the input AO | |
54 if size(bs.data.y, 1) == 1 | |
55 y = y.'; | |
56 end | |
57 | |
58 % make a new tsdata object | |
59 fsd = tsdata(y, fs); | |
60 fsd.setXunits('s'); | |
61 fsd.setYunits(bs.yunits); | |
62 | |
63 % Set data | |
64 bs.data = fsd; | |
65 % clear errors | |
66 bs.clearErrors; | |
67 | |
68 case {'tsdata', 'cdata', 'xydata'} | |
69 error('### I don''t work for time-series, constant or x/y data.'); | |
70 otherwise | |
71 error('### unknown data type.') | |
72 end | |
73 | |
74 | |
75 end | |
76 | |
77 | |
78 | |
79 |