% *** plotSOAEwf.m *** 10/27/06 % code to fiddle w/ SOAE time waveform taken using RECsoae.cpp % specifiable parameters file='./T4learSOAEwf1.txt'; % SOAE time waveform (assumes SR=22050 Hz) n=1; % where to start along waveform (default =1) N=100; % # of averages to take (default=60) nPts=8192; % # of points in FFT buffer (default=8192) SR=22050; % sample rate (needed to determine freq. bins) % ----------------------------------------------- wf=load(file); time=[0:1/22050:30]; time=time(1:end-1); for i=1:N spec=wf(n:n+nPts-1); mag= abs(rfft(spec)); if i==1 avgMAG= mag/N; else avgMAG= avgMAG + mag/N; end n=n+nPts+round(nPts*0.1); % jump ahead to next section plus a bit xtra end freq=[0:SR/nPts:(SR+1)/2]; % this is likely wrong plot(freq,db(avgMAG)); axis([0 5000 min(db(avgMAG)) max(db(avgMAG))-5]) grid on; xlabel('freq. [Hz]') ylabel('mag. [dB, arbitrary]') title(['SOAE spectrum taken from averaged segments of time waveform (', file,')'])