quasidct.sci

来自「小波分解源代码」· SCI 代码 · 共 40 行

SCI
40
字号
function c = QuasiDCT(x,dir)
// QuasiDCT -- Nearly Discrete Cosine Transform of Type I.
//   Usage
//    c = QuasiDCT(x,dir)
//  Inputs
//    x     signal of dyadic length
//    dir   string direction indicator 'f' forward ; 'i' inverse 
//  Outputs
//    c     discrete cosine transform, type I, of x
//
// See Also
//    CoarseMeyerCoeff, CoarseMeyerProj
//  Copyright Aldo I Maalouf

	n = length2(x) - 1;

// Modifications of signal and sampling of transform are
// different for forward and inverse Meyer wavelet transforms.

	if ( dir == 'f' ),
	  x(1) = x(1)/sqrt(2); x(n+1) = x(n+1)/sqrt(2);
	  rx = matrix( [ x ; zeros(1,n+1) ],1,(2*n+2) );
	  y = [ rx zeros(1,2*n-2) ];
	  w = real(mtlb_fft(y)) ;
	  c = sqrt(2/n)*waverow(w(1:2:n+1));
	  c(1) = c(1)/sqrt(2);
	
	elseif ( dir == 'i' ),
	   x(1)  = x(1)/sqrt(2); 
	   rx    = matrix( [ x ; zeros(1,n+1) ],1,2*(n+1) );
	   y     = rx;
	   w     = real(mtlb_fft(y));
	   c     = sqrt(2/(n+1))*waverow(w(1:n+2));
	  c(1)   = c(1)/sqrt(2);
	  c(n+2) = c(n+2)/sqrt(2);
	end
	endfunction
	  

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?