view lotplot.m @ 17:0da5eb32e49d tip

minor changes
author Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk>
date Thu, 10 Nov 2011 15:53:06 +0000
parents 2e42f5fb764d
children
line wrap: on
line source
function varargout = lotplot(y,wLength,Fs)
% LOTPLOT plot of the lapped orthogonal transform
%
% Example
% varargout = lappedorthoplot(y,wLength,timeVec) 
% 
% plots a spectrogram-like visualisation of the lapped orthogonal
% transform coefficients contained in y
%
% Input
% - y: vector containing the lapped orthogonal transform coefficients
% - wLength: vector containing the lengths of the overlapping windows
% - Fs: (optional, default=44100) sampling frequency
%
% Output
% - varargout{1}: optionally, the function outputs the matrix containing 
% the spectrogram-like representation.
%
% See also lot, ilot

% Author(s): Daniele Barchiesi
% Copyright 2011-2011

if ~exist('Fs','var') || isempty(Fs), Fs = 44100; end
if isscalar(wLength) %create vector of fixed window lengths
    nWindows = floor(length(y)/wLength);
    wLength = wLength*ones(nWindows,1);
end

nWindows = length(wLength);
maxLength = max(wLength);
sigLength = sum(wLength);

timeVec = linspace(0,sigLength/Fs,nWindows); 

S = zeros(maxLength,nWindows);
timeSupp  = @(p) floor(wLength(p)*length(timeVec)/sigLength);
interpFun = @(p,v) interp1(1:wLength(p),abs(v),linspace(1,wLength(p),maxLength))';
S(:,1) = repmat(interpFun(1,y(1:wLength(1))),1,1);
for i=2:nWindows
    S(:,i) = ...
        mag2db(repmat(interpFun(i,y(sum(wLength(1:i-1))+(1:wLength(i)))),1,1));
end

if nargout, varargout{1} = S; end

surf(timeVec,(1:maxLength)/maxLength*Fs/2,S,'EdgeColor','none');
axis xy; axis tight;
colormap(jet);
view(0,90);
set(gca,'YScale','log');
xlabel('time (sec)');
ylabel('frequency (Hz)');