v_irdct

PURPOSE ^

V_IRDCT Inverse discrete cosine transform of real data X=(Y,N)

SYNOPSIS ^

function x=v_irdct(y,n,a,b)

DESCRIPTION ^

V_IRDCT    Inverse discrete cosine transform of real data X=(Y,N) 
 Data is truncated/padded to length N.

 This routine is equivalent to multiplying by the matrix

    irdct(eye(n)) = cos((0.5:n)'*(0:n-1)*pi/n)*diag([sqrt(0.5)*a/b repmat(a,1,n-1)])/n


 Default values of the scaling factors are A=sqrt(2N) and B=1 which
 results in an orthogonal matrix. Other common values are A=1 or N and/or B=1 or sqrt(2). 
 If b~=1 then the columns are no longer orthogonal.
 See also RCDT

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function x=v_irdct(y,n,a,b)
0002 %V_IRDCT    Inverse discrete cosine transform of real data X=(Y,N)
0003 % Data is truncated/padded to length N.
0004 %
0005 % This routine is equivalent to multiplying by the matrix
0006 %
0007 %    irdct(eye(n)) = cos((0.5:n)'*(0:n-1)*pi/n)*diag([sqrt(0.5)*a/b repmat(a,1,n-1)])/n
0008 %
0009 %
0010 % Default values of the scaling factors are A=sqrt(2N) and B=1 which
0011 % results in an orthogonal matrix. Other common values are A=1 or N and/or B=1 or sqrt(2).
0012 % If b~=1 then the columns are no longer orthogonal.
0013 % See also RCDT
0014 
0015 %      Copyright (C) Mike Brookes 1998
0016 %      Version: $Id: v_irdct.m 10865 2018-09-21 17:22:45Z dmb $
0017 %
0018 %   VOICEBOX is a MATLAB toolbox for speech processing.
0019 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
0020 %
0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0022 %   This program is free software; you can redistribute it and/or modify
0023 %   it under the terms of the GNU General Public License as published by
0024 %   the Free Software Foundation; either version 2 of the License, or
0025 %   (at your option) any later version.
0026 %
0027 %   This program is distributed in the hope that it will be useful,
0028 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0029 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0030 %   GNU General Public License for more details.
0031 %
0032 %   You can obtain a copy of the GNU General Public License from
0033 %   http://www.gnu.org/copyleft/gpl.html or by writing to
0034 %   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
0035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0036 
0037 fl=size(y,1)==1;
0038 if fl y=y(:); end
0039 [m,k]=size(y);
0040 if nargin<4 b=1;
0041     if nargin<3 a=sqrt(2*m);
0042         if nargin<2 n=m;
0043         end
0044     end
0045 end
0046 if n>m y=[y; zeros(n-m,k)];
0047 elseif n<m y(n+1:m,:)=[];
0048 end
0049 
0050 x=zeros(n,k);
0051 w=ones(1,k);
0052 m=fix((n+1)/2);
0053 p=n-m;
0054 z=0.5*exp((0.5i*pi/n)*(1:p)).';
0055 u=(y(2:p+1,:)-1i*y(n:-1:m+1,:)).*z(:,w)*a;
0056 y=[y(1,:)*sqrt(0.5)*a/b; u(1:m-1,:)];
0057 if m==p
0058     z=-0.5i*exp((2i*pi/n)*(0:m-1)).';
0059     y=(z(:,w)+0.5).*(conj(flipud(u))-y)+y;
0060     z=ifft(y,[],1);
0061     u=real(z);
0062     y=imag(z);
0063     q=m/2;
0064     h=rem(m,2)/2;
0065     x(1:4:n,:)=u(1:q+h,:);
0066     x(2:4:n,:)=y(m:-1:q+1-h,:);
0067     x(3:4:n,:)=y(1:q-h,:);
0068     x(4:4:n,:)=u(m:-1:q+1+h,:);
0069 else
0070     z=real(ifft([y; conj(flipud(u))]));
0071     x(1:2:n,:)=z(1:m,:);
0072     x(2:2:n,:)=z(n:-1:m+1,:);
0073 end
0074 
0075 if fl x=x.'; end

Generated by m2html © 2003