tp@0: function Bigir = EDB1plotstackedIRs(firstirfile,nfiles,offset,filtir,typeofir,startsample,endsample) tp@0: % EDB1plotstackedIRs - Plots a number of IRs in a stacked way. tp@0: % tp@0: % Input parameters: tp@0: % firstirfile The data file containing the first IR file tp@0: % nfiles The number of files tp@0: % offset The numerical offset for each file tp@0: % filtir A window to filter with tp@0: % typeofir 't' (default), 'g' (geom), 'f' (direct sound), 'd' tp@0: % (diffracted) tp@0: % startsample (optional) The first sample number that should be tp@0: % plotted for each IR (after filtering). Default: 1. tp@0: % endsample (optional) The last sample number that should be tp@0: % plotted for each IR (after filtering). Default: the tp@0: % last sample for the longest of all IRs. tp@0: % tp@0: % Output parameters: tp@0: % Bigir Matrix, [nfiles,nlength], of the IRs in the files, one tp@0: % per row. tp@0: % tp@0: % Uses functions EDB1strpend tp@0: % tp@0: % ---------------------------------------------------------------------------------------------- tp@0: % This file is part of the Edge Diffraction Toolbox by Peter Svensson. tp@0: % tp@0: % The Edge Diffraction Toolbox is free software: you can redistribute it and/or modify tp@0: % it under the terms of the GNU General Public License as published by the Free Software tp@0: % Foundation, either version 3 of the License, or (at your option) any later version. tp@0: % tp@0: % The Edge Diffraction Toolbox is distributed in the hope that it will be useful, tp@0: % but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS tp@0: % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. tp@0: % tp@0: % You should have received a copy of the GNU General Public License along with the tp@0: % Edge Diffraction Toolbox. If not, see . tp@0: % ---------------------------------------------------------------------------------------------- tp@0: % Peter Svensson (svensson@iet.ntnu.no) 20030806 tp@0: % tp@0: % EDB1plotstackedIRs(firstirfile,nfiles,offset,filtir,typeofirs,startsample,endsample); tp@0: tp@0: %-------------------------------------------------------------- tp@0: % Extract the filename stem tp@0: tp@0: if nargin == 0 tp@0: [firstirfile,irfilepath] = uigetfile('*ir.mat','Please select the first irfile'); tp@0: [irfilepath,temp1,temp2] = fileparts(irfilepath); tp@0: if ~isstr(firstirfile) | isempty(firstirfile) tp@0: return tp@0: end tp@0: else tp@0: [irfilepath,firstirfile,fileext] = fileparts(firstirfile); tp@0: irfilepath = [irfilepath,filesep]; tp@0: firstirfile = [firstirfile,fileext]; tp@0: end tp@0: tp@0: if nargin < 5 tp@0: typeofir = 't'; tp@0: else tp@0: typeofir = lower(typeofir(1)); tp@0: end tp@0: tp@0: if nargin < 6 tp@0: startsample = 1; tp@0: end tp@0: if nargin < 7 tp@0: endsample = -1; tp@0: end tp@0: tp@0: filestem = EDB1strpend(firstirfile,'_ir'); tp@0: iv = find(filestem=='_'); tp@0: iv = iv(length(iv)); tp@0: firstnumber = str2num(filestem(iv+1:length(filestem))); tp@0: filestem = filestem(1:iv) tp@0: tp@0: %-------------------------------------------------------------- tp@0: % Read the files tp@0: tp@0: offsetvec = ([1:nfiles].'-1)*offset; tp@0: tp@0: disp(' Loading files') tp@0: for ii = nfiles:-1:1 tp@0: irfile = [filestem,int2str(ii+firstnumber-1),'_ir.mat']; tp@0: eval(['load ',irfilepath,irfile]) tp@0: irtot = real(irtot); tp@0: if typeofir == 'f' tp@0: irtot = irdirect; tp@0: elseif typeofir == 'g' tp@0: irtot = irgeom + irdirect; tp@0: elseif typeofir == 's' tp@0: irtot = irgeom; tp@0: elseif typeofir == 'd' tp@0: irtot = real(irdiff); tp@0: end tp@0: tp@0: if isempty(irtot) tp@0: irtot = [0 0].'; tp@0: end tp@0: tp@0: irtot = conv(filtir,full(irtot)); tp@0: if endsample == -1 tp@0: irtot = irtot(startsample:end); tp@0: else tp@0: if endsample <= length(irtot) tp@0: irtot = irtot(startsample:endsample); tp@0: else tp@0: irtot = irtot(startsample:end); tp@0: end tp@0: end tp@0: tp@0: signvec = sign(irtot); tp@0: irtot = abs(irtot).^(1/1).*signvec; tp@0: tp@0: if ii == nfiles tp@0: Bigir = zeros(nfiles,length(irtot)); tp@0: [slask,nbigir] = size(Bigir); tp@0: Bigir = Bigir + offsetvec(:,ones(1,nbigir)); tp@0: Bigir(ii,:) = Bigir(ii,:) + (irtot).'; tp@0: else tp@0: [slask,nbigir] = size(Bigir); tp@0: nir = length(irtot); tp@0: if nir > nbigir tp@0: Bigir = [Bigir offsetvec(:,ones(1,nir-nbigir))]; tp@0: end tp@0: Bigir(ii,1:nir) = Bigir(ii,1:nir) + (irtot).'; tp@0: end tp@0: tp@0: end tp@0: tp@0: if ~isempty(Bigir) tp@0: plot(Bigir.','r') tp@0: else tp@0: error(' ERROR: The IRs were all empty. Please check that you did not specify start and end samples that were longer than the IR length!') tp@0: end