view orthohandle.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 88af68016e8a
children
line wrap: on
line source
function orthoFun = orthohandle(orthoBasis,dir)
% ORTHOHANDLE local orthogonal transform string to function handle
%
% Example
% orthoFun = orthohandle(orthoBasis,dir)
%
% Input
% - orthoBasis: either a string or a function handle corresponding to an
% orhogonal transform to be used in each overlapping window. The available
% forward transforms are
%   'mdct': modified discrete transform, uses local DCT-IV and DCT-I for
%   last block of data.
%   'fft': Fourier transform
%   'id': Identity
%
% - dir: either 'for' or 'inv' for the forward and inverse transform
% respectively.
%
% Output
% - orthoFun: handle to the orthogonal function
%
% Reference
% S. Mallat, A Wavelet Tour of Signal Processing
%
% See also LOT, ILOT

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

if ischar(orthoBasis) %if string parse input
    if strcmpi(dir,'for') %forward transform
        switch orthoBasis
            case 'mdct'
                orthoFun = @(x) dcti(x,'IV');
            case 'id'
                orthoFun = @(x) x;
            case 'fft'
                orthoFun = @(x) fft(x);
            otherwise
                error('invalid basis function');
        end
    elseif strcmpi(dir,'inv') %inverse transform
        switch orthoBasis
            case 'mdct'
                orthoFun = @(y) idcti(y,'IV');
            case 'id'
                orthoFun = @(y) y;
            case 'fft'
                orthoFun = @(y) ifft(y);
            otherwise
                error('invalid basis function');
        end
    end
elseif isa(orthoBasis,'function_handle') %if function handle do nothing
    orthoFun = orthoBasis;
else
    error('invalid basis function');
end