annotate util/classes/dictionaryMatrices/dctmatrix.m @ 160:e3035d45d014 danieleb

Added support classes
author Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk>
date Wed, 31 Aug 2011 10:53:10 +0100
parents
children
rev   line source
daniele@160 1 function D = dctmatrix(N,K,type)
daniele@160 2
daniele@160 3 error(nargchk(1,3,nargin,'struct'));
daniele@160 4 if ~exist('type','var') || isempty(type), type='II'; end
daniele@160 5 if ~exist('K','var') || isempty(K), K=N; end
daniele@160 6
daniele@160 7 [c r] = meshgrid(0:K-1,0:N-1);
daniele@160 8 switch type
daniele@160 9 case 'I'
daniele@160 10 D = cos(pi*c.*r/(K-1));
daniele@160 11 D(1,:) = D(1,:)/sqrt(2);
daniele@160 12 D(end,:) = D(end,:)/sqrt(2);
daniele@160 13 case 'II'
daniele@160 14 D = cos(pi*(2*c+1).*r/(2*K));
daniele@160 15 D(1,:) = D(1,:)/sqrt(2);
daniele@160 16 case 'III'
daniele@160 17 D = cos(pi*(2*r+1).*c/(2*K));
daniele@160 18 D(:,1) = D(:,1)/sqrt(2);
daniele@160 19 case 'IV'
daniele@160 20 D = cos(pi*(2*r+1+2*c+4*c.*r)/(4*K));
daniele@160 21 otherwise
daniele@160 22 error('unsupported dct type');
daniele@160 23 end
daniele@160 24 D = normcol(D);