tp@0
|
1 function Bigtf = EDB1plotstackedTFs(firstirfile,nfiles,offset,nfft,typeofir,startsample,endsample)
|
tp@0
|
2 % EDB1plotstackedTFs - Plots a number of TFs in a stacked way.
|
tp@0
|
3 %
|
tp@0
|
4 % Input parameters:
|
tp@0
|
5 % firstirfile The data file containing the first IR file
|
tp@0
|
6 % nfiles The number of files
|
tp@0
|
7 % offset The numerical offset for each file [in dB]
|
tp@0
|
8 % nfft The fft size
|
tp@0
|
9 % typeofir 't' (default), 'g' (geom), 'f' (direct sound), 'd'
|
tp@0
|
10 % (diffracted)
|
tp@0
|
11 % startsample (optional) The first sample number that should be
|
tp@0
|
12 % plotted for each IR (after filtering). Default: 1.
|
tp@0
|
13 % endsample (optional) The last sample number that should be
|
tp@0
|
14 % plotted for each IR (after filtering). Default: the
|
tp@0
|
15 % last sample for the longest of all IRs.
|
tp@0
|
16 %
|
tp@0
|
17 % Output parameters:
|
tp@0
|
18 % Bigtf Matrix, [nfiles,nlength], of the TFs in the files, one
|
tp@0
|
19 % per row.
|
tp@0
|
20 %
|
tp@0
|
21 % Uses functions EDB1strpend
|
tp@0
|
22 %
|
tp@0
|
23 % ----------------------------------------------------------------------------------------------
|
tp@0
|
24 % This file is part of the Edge Diffraction Toolbox by Peter Svensson.
|
tp@0
|
25 %
|
tp@0
|
26 % The Edge Diffraction Toolbox is free software: you can redistribute it and/or modify
|
tp@0
|
27 % it under the terms of the GNU General Public License as published by the Free Software
|
tp@0
|
28 % Foundation, either version 3 of the License, or (at your option) any later version.
|
tp@0
|
29 %
|
tp@0
|
30 % The Edge Diffraction Toolbox is distributed in the hope that it will be useful,
|
tp@0
|
31 % but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
tp@0
|
32 % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
tp@0
|
33 %
|
tp@0
|
34 % You should have received a copy of the GNU General Public License along with the
|
tp@0
|
35 % Edge Diffraction Toolbox. If not, see <http://www.gnu.org/licenses/>.
|
tp@0
|
36 % ----------------------------------------------------------------------------------------------
|
tp@0
|
37 % Peter Svensson (svensson@iet.ntnu.no) 20050116
|
tp@0
|
38 %
|
tp@0
|
39 % EDB1plotstackedTFs(firstirfile,nfiles,offset,nfft,typeofirs,startsample,endsample);
|
tp@0
|
40
|
tp@0
|
41 %--------------------------------------------------------------
|
tp@0
|
42 % Extract the filename stem
|
tp@0
|
43
|
tp@0
|
44 if nargin == 0
|
tp@0
|
45 [firstirfile,irfilepath] = uigetfile('*ir.mat','Please select the first irfile');
|
tp@0
|
46 [irfilepath,temp1,temp2] = fileparts(irfilepath);
|
tp@0
|
47 if ~isstr(firstirfile) | isempty(firstirfile)
|
tp@0
|
48 return
|
tp@0
|
49 end
|
tp@0
|
50 else
|
tp@0
|
51 [irfilepath,firstirfile,fileext] = fileparts(firstirfile);
|
tp@0
|
52 irfilepath = [irfilepath,filesep];
|
tp@0
|
53 firstirfile = [firstirfile,fileext];
|
tp@0
|
54 end
|
tp@0
|
55
|
tp@0
|
56 if nargin < 5
|
tp@0
|
57 typeofir = 't';
|
tp@0
|
58 else
|
tp@0
|
59 typeofir = lower(typeofir(1));
|
tp@0
|
60 end
|
tp@0
|
61
|
tp@0
|
62 if nargin < 6
|
tp@0
|
63 startsample = 1;
|
tp@0
|
64 end
|
tp@0
|
65 if nargin < 7
|
tp@0
|
66 endsample = -1;
|
tp@0
|
67 end
|
tp@0
|
68
|
tp@0
|
69 filestem = EDB1strpend(firstirfile,'_ir');
|
tp@0
|
70 iv = find(filestem=='_');
|
tp@0
|
71 iv = iv(length(iv));
|
tp@0
|
72 firstnumber = str2num(filestem(iv+1:length(filestem)));
|
tp@0
|
73 filestem = filestem(1:iv)
|
tp@0
|
74
|
tp@0
|
75 %--------------------------------------------------------------
|
tp@0
|
76 % Read the files
|
tp@0
|
77
|
tp@0
|
78 offsetvec = ([1:nfiles].'-1)*offset;
|
tp@0
|
79
|
tp@0
|
80 disp(' Loading files')
|
tp@0
|
81 for ii = nfiles:-1:1
|
tp@0
|
82 irfile = [filestem,int2str(ii+firstnumber-1),'_ir.mat'];
|
tp@0
|
83 eval(['load ',irfilepath,irfile])
|
tp@0
|
84 irtot = real(irtot);
|
tp@0
|
85 if typeofir == 'f'
|
tp@0
|
86 irtot = irdirect;
|
tp@0
|
87 elseif typeofir == 'g'
|
tp@0
|
88 irtot = irgeom + irdirect;
|
tp@0
|
89 elseif typeofir == 's'
|
tp@0
|
90 irtot = irgeom;
|
tp@0
|
91 elseif typeofir == 'd'
|
tp@0
|
92 irtot = real(irdiff);
|
tp@0
|
93 end
|
tp@0
|
94
|
tp@0
|
95 if isempty(irtot)
|
tp@0
|
96 irtot = [0 0].';
|
tp@0
|
97 end
|
tp@0
|
98
|
tp@0
|
99 if endsample == -1
|
tp@0
|
100 irtot = irtot(startsample:end);
|
tp@0
|
101 else
|
tp@0
|
102 if endsample <= length(irtot)
|
tp@0
|
103 irtot = irtot(startsample:endsample);
|
tp@0
|
104 else
|
tp@0
|
105 irtot = irtot(startsample:end);
|
tp@0
|
106 end
|
tp@0
|
107 end
|
tp@0
|
108 F = fft(full(irtot),nfft);
|
tp@0
|
109 L = 20*log10(abs(F(1:nfft/2)));
|
tp@0
|
110
|
tp@0
|
111 if ii == nfiles
|
tp@0
|
112 Bigtf = zeros(nfiles,nfft/2);
|
tp@0
|
113 BigL = zeros(nfiles,nfft/2);
|
tp@0
|
114 [slask,nbigtf] = size(Bigtf);
|
tp@0
|
115 BigL = BigL + offsetvec(:,ones(1,nbigtf));
|
tp@0
|
116 Bigtf(ii,:) = (F(1:nfft/2)).';
|
tp@0
|
117 BigL(ii,:) = BigL(ii,:) + (L).';
|
tp@0
|
118 else
|
tp@0
|
119 Bigtf(ii,:) = (F(1:nfft/2)).';
|
tp@0
|
120 BigL(ii,:) = BigL(ii,:) + (L).';
|
tp@0
|
121 end
|
tp@0
|
122
|
tp@0
|
123 end
|
tp@0
|
124
|
tp@0
|
125 fvec = FSAMP/nfft*[0:nfft/2-1];
|
tp@0
|
126 semilogx(fvec,BigL.','r')
|