function vector=haar_inv(coef) % Haar inverse transform % % Syntax VECTOR=HARR_INV(COEF) % This function returns the inverse Haar wavelet transform of the % data in COEF. The number of elements in COEF must be a power of two. % VECTOR has length equal to a power of two. % % Written by Eric Tittley (940901) etittley@phobos.astro.uwo.ca % % See also HAAR if nargin<1 error('Too few arguments passed to haar'); end if nargin>1 error('Too many arguments passed to haar'); end n=length(coef); k=0; while(n>2^k) k=k+1; end pow=k; if(n~=2^k) error('Length of COEF must be a power of 2 in call to HAAR_INV'); end coef=coef(:); vector=coef; for k=1:pow avg=vector(1:2^(k-1)); diff=vector(2^(k-1)+1:2^k); for l=1:2^(k-1) vector(2*l-1)=avg(l)+diff(l); vector(2*l)=avg(l)-diff(l); end end