Please help me convert equation to matlab code.

Deal all.
I need you help to convert this equation to matlab code to plot DCT basis function graph.
Equation is in
at equation (1) and (2).
*I'm not a student in this class but I need DCT concept to write code.
I spend a lot of time to write it but it doesn't work.
Please help me. I must have DCT basis function for my work.
Best regard.
ps. If you have DCT basis function, please share it to me.

回答 (1 件)

Matt Tearle
Matt Tearle 2012 年 2 月 15 日

0 投票

Assuming that x is a column vector
N = length(x);
k = 0:(N-1);
DCTbasis = cos(k'*(2*k+1)*pi/(2*N));
w = sqrt(2/N)*DCTbasis*x;
w(1) = w(1)/sqrt(2);
will do the job. If you have Signal Processing Toolbox, so will
w = dct(x);
:)

2 件のコメント

N K
N K 2012 年 2 月 15 日
Thanks for you answer.
So if I want to plot dct basis function graph follow this picture.
(DCT 8 point)
http://instruct1.cit.cornell.edu/courses/ee476/Math/DCTIIbasis8.png
could you tell me how to do that (I'm novice in matlab).
best.
Matt Tearle
Matt Tearle 2012 年 2 月 15 日
I'm not sure what you're trying to achieve with your follow-up question. It looks a lot like Q 1.1 in the lab, but you already found a nice visualization. I don't see what recreating the visualization in MATLAB will gain you -- it's messy because the visualization is plotting the underlying continuous function, not just the 8 sample points. If you run the code I gave, with x being any 8-by-1 vector, then the rows of the DCTbasis matrix will be the values of the basis functions, at the sample locations.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

製品

質問済み:

N K
2012 年 2 月 15 日

編集済み:

2013 年 10 月 13 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by