フィルターのクリア

Discrete Cosine Transform help

1 回表示 (過去 30 日間)
Cagdas
Cagdas 2013 年 12 月 31 日
コメント済み: Cagdas 2013 年 12 月 31 日
Hi everyone, i am trying to take the discrete cosine transform of a matrix by coding it in a script. However results does not match with the results of the DCT command of Matlab. I tried to code the equation in the following link http://www.mathworks.com/help/signal/ref/dct.html
The input matrix is 12x12 and script will take dct of every row seperately. Any help will be appreciated. Thank you.
script:
function[aray] = dis(filter)
b1 = 1; n = 1; k = 1; N = 12; wk = 0; yk = 0;
while(b1 < 13)
while(n < N+1)
while(k < N+1)
if(k == 1)
wk = 1/(sqrt(N));
else
wk = sqrt(2/N);
end;
yk = yk + wk*filter(b1,n)*cos(pi*(2*(2*n-1)*(k-1))/2*N);
k = k + 1;
end;
aray(b1,n) = yk;
yk = 0;
k = 1;
n = n + 1;
end;
n = 1;
b1 = b1 + 1;
end;
end
Matrix is:
3510 3130 3480 3590 3550 3460 3490 3490 3380 2870 3230 3540
2140 3030 3430 3210 3470 3250 3280 2970 3240 3290 3490 2950
3610 3010 3400 3170 3610 3160 3350 3360 3550 3210 3460 2930
3050 2720 2610 3610 2490 1680 3100 3020 2390 2350 2630 2890
3480 3420 1960 3070 3520 3360 3560 3570 3600 2770 3520 3460
3470 3500 3450 3520 3480 2440 2380 2770 3310 3600 3080 1660
1230 3310 3050 3520 3120 3280 3370 3570 2920 2880 3130 3000
3120 3120 2840 3430 3330 3130 3340 2350 2700 2870 3220 2820
3120 2450 3350 3260 3430 2960 3600 3360 3610 3350 3530 3530
3390 3190 3530 1600 3070 3090 3260 3290 2860 3610 3370 3430
3250 3430 3600 3390 3390 3440 3390 3320 3280 3580 3500 2840
3190 3490 3520 3500 3170 3170 3340 3130 3130 2740 3160 3510

回答 (1 件)

Wayne King
Wayne King 2013 年 12 月 31 日
You are not coding it as written in the documentation, why are you using filter()?
  3 件のコメント
Wayne King
Wayne King 2013 年 12 月 31 日
oh sorry, naming your input matrix filter() is not a good idea.
Cagdas
Cagdas 2013 年 12 月 31 日
i agree. have you got any suggestions about implementing dct code?

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by