1
$\begingroup$

How can I generate an NxM DCT matrix? In Matlab dctmtx function generates only square matrix (NxN).

$\endgroup$
0
$\begingroup$
type dctmtx

you will get:

function c = dctmtx(n) 
[cc,rr] = meshgrid(0:n-1); 
c = sqrt(2 / n) * cos(pi * (2*cc + 1) .* rr / (2 * n)); 
c(1,:) = c(1,:) / sqrt(2); 

So it's not that hard to generate an non-square DCT matrix, just with minor revision:

function c = dctmtx1(n,m) 
[cc,rr] = meshgrid(0:n-1, 0:m-1); 
c = sqrt(2 / n) * cos(pi * (2*cc + 1) .* rr / (2 * n)); 
c(1,:) = c(1,:) / sqrt(2); 
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.