Search code examples
pythonmatlabnumpyscipydct

How to call the library in Python to achieve the same function as dctmtx(N) in matlab


In Python, dct() in scipy is similar to dct2() in matlab, so is there a library similar to dctmtx in matlab in Python?


Solution

  • To get the same result as D = dctmtx(n) in Matlab, you can use

    D = dct(np.eye(n), norm='ortho', axis=0)
    

    Paul Panzer's suggestion should also work fine, and might even be a bit faster.