找回密码
 注册
关于网站域名变更的通知
查看: 522|回复: 1
打印 上一主题 下一主题

MATLAB 信号处理工具箱之 idct 介绍和案例分析

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2019-12-27 10:08 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x
/ \; h# N8 u$ N$ E
有关idct的基础知识见:MATLAB 基础知识之逆离散余弦变换(idct)# ~. _$ v2 V2 U2 t
1 j1 G' k# j9 G3 A1 [
idct
4 R+ G- [: o) t! V! S
0 t. k6 N% Q; C% \) c. d逆离散余弦变换
9 n7 q& Q' |/ F' k/ @. Y* D  o; v1 X/ V4 ^' I
Syntax5 }# \! T8 U, J% q# R5 N( N1 ~
, U" E2 B% C2 \/ }1 H: s0 E  m5 v( x& d
x = idct(y)
% I! X# E, V$ r' p% Z6 ^( i* L1 ?$ M5 [4 y, s6 ^' P, _
x = idct(y,n)
8 Z: u0 d* V# l# K) w" M* z+ K8 s
x = idct(y,n,dim)) [$ k- J/ s- C0 U2 H  ]- j

2 x3 {8 a! a6 d6 Hy = dct(___,'Type',dcttype)9 ]8 k% a% M6 o. _! K
4 a0 w- R+ \9 X8 H( a; }
Description
( ^5 \6 z, ^. V2 A. M7 H% [# D" G
1 g. J# n- \. I8 R( H  px = idct (y) 返回输入数组 y 的逆离散余弦变换。输出 x 的大小与 y 相同。如果 y 具有多个维度, 则 idct 沿第一个数组维度运行, 大小大于1。
$ T7 R+ w6 L' `' ?
: B, L0 z6 l; vx = idct (y, n) 填充0或截断 y 到长度 n 在转换前的相关维度。5 m1 I+ l2 j- Y& M% d
$ K' D9 W7 q! v8 `; @" n
x = idct (y、n、dim) 计算沿维度dim的变换。若要输入维度并使用默认值 n, 请将第二个参数指定为空 []。
3 x9 o% D" N8 |3 v8 V9 [
0 V  N( o; {. u* Ty = dct(___,'Type',dcttype) specifies the type of inverse discrete cosine transform to compute.
. z. f! h) z/ s* D& n0 C! d
0 z. K2 w- F' z5 p2 @Signal Reconstruction Using Inverse Discrete Cosine Transform
3 E3 w/ n' `( Z0 v7 [& B! b/ H

- c" a0 _7 V) q8 ]5 p5 g6 Y生成一个信号, 由 25 hz 正弦采样 1000 hz 1 秒。正弦波嵌入在具有方差0.01 的白色高斯噪声中。
9 J, V2 H8 k$ u9 ~) Y: c; {2 f- b" |5 s
  • clc
  • clear
  • close all
  • % Generate a signal that consists of a 25 Hz sinusoid sampled at 1000 Hz for 1 second.
  • % The sinusoid is embedded in white Gaussian noise with variance 0.01.
  • rng('default')
  • Fs = 1000;
  • t = 0:1/Fs:1-1/Fs;
  • x = sin(2*pi*25*t) + randn(size(t))/10;
  • % 计算序列的离散余弦变换。
  • % 确定1000个 DCT 系数中有多少是显著的。
  • % 选择1作为重要性的阈值。
  • y = dct(x);
  • sigcoeff = abs(y) >= 1;
  • howmany = sum(sigcoeff)
  • % Reconstruct the signal using only the significant components.
  • y(~sigcoeff) = 0;      %~ means not
  • z = idct(y);
  • % Plot the original and reconstructed signals.
  • subplot(2,1,1)
  • plot(t,x)
  • yl = ylim;
  • title('Original')
  • subplot(2,1,2)
  • plot(t,z)
  • ylim(yl)
  • title('Reconstructed')1 \1 {2 x3 J) L) ]
            
7 ^& {8 g2 L7 N' J* e& P上面这段程序中,简单地做几点解释:
) K3 q0 O/ p4 S- {' ^7 W8 v( @1 a( A+ b/ Q6 n
sigcoeff = abs(y) >= 1;
4 r: m& D$ c) w- U4 U( h% c
+ F8 |4 F# F0 m7 j% Q# e, U由于1是阈值,所以判断向量y中元素大于阈值的元素个数,这条语句可以改写为:sigcoeff = ( abs(y) >= 1 ) ;这样可以更清晰。
& [4 Y, l3 r9 Q0 O
6 B6 h/ q4 E+ Y$ Ysigcoeff向量中得到的是逻辑值,元素1代表该位置的系数元素大于阈值。
& B) x& ?8 Y: L7 p' r1 Y" p1 I. X8 e% e: Y1 b
后面用语句:howmany = sum(sigcoeff);& m2 U- ]. Z; _* w9 W

/ N# @9 g8 t0 a5 V) y! o得到系数中大于阈值的个数,也就是重要系数个数。8 ]9 K, ^# }- C, ^4 O9 X
* H" T" H' |% Z" H% c7 I3 |
y(~sigcoeff) = 0;      %~ means not
9 u. g  Z8 w5 s* m) q: f- z: w* f8 F9 |3 ^1 ]4 p9 W
这条语句的意思是将系数中的不重要的系数都置零。7 |6 g) i( _, h. F7 F
6 D! s% \* m0 ^  O% `# c, z0 H9 s
最后:yl = ylim;表示获取当前x,y坐标轴的限制。
; z! ^. V8 Q4 c* V0 \" b
" I6 G% C; x& kylim(yl);表示当前画图的x,y坐标轴的限制和yl一致。
* W; [# X! C7 W: n: o* R4 I
( m. e- G- n9 C1 `) X) @结果为:
! Y. z  y& p' N+ v6 A6 U; T1 W
* E8 ~" P% k7 m4 \
: E$ Z6 X; @& E
/ u) E8 Z2 D0 S5 p; L$ uDCT Orthogonality2 N( o  _0 d" E1 p, P, V
8 i. ]4 l' P$ Y; L# j# w% c' x! A" N
验证离散余弦变换的不同变体是否正交, 使用随机信号作为基准。( s. m4 E1 }# y

. v! [) N" u' P9 \7 u从生成信号开始。
# e( ?- k8 |! r4 V; F6 n- C
* K6 L) y  v' N: n. y6 Q
  • clc
  • clear
  • close all
  • % Verify that the different variants of the discrete cosine transform are orthogonal, using a random signal as a benchmark.
  • %
  • % Start by generating the signal.
  • s = randn(1000,1);
  • % Verify that DCT-1 and DCT-4 are their own inverses.
  • dct1 = dct(s,'Type',1);
  • idt1 = idct(s,'Type',1);
  • max(abs(dct1-idt1))
  • % ans = 1.3323e-15
  • dct4 = dct(s,'Type',4);
  • idt4 = idct(s,'Type',4);
  • max(abs(dct4-idt4))
  • % ans = 1.3323e-15
  • % Verify that DCT-2 and DCT-3 are inverses of each other.
  • dct2 = dct(s,'Type',2);
  • idt2 = idct(s,'Type',3);
  • max(abs(dct2-idt2))
  • % ans = 4.4409e-16
  • dct3 = dct(s,'Type',3);
  • idt3 = idct(s,'Type',2);
  • max(abs(dct3-idt3))
  • % ans = 1.1102e-15
    6 R' {& ^% G. [
         
! p3 X+ X' P3 l( N3 U# d$ G
. |9 K$ C9 \3 l3 ]- Y. I. C% j6 G$ m, D+ ]% p
  • TA的每日心情

    2019-11-29 15:37
  • 签到天数: 1 天

    [LV.1]初来乍到

    2#
    发表于 2019-12-27 18:28 | 只看该作者
    学习啦,谢谢分享
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    关闭

    推荐内容上一条 /1 下一条

    EDA365公众号

    关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

    GMT+8, 2025-11-1 20:27 , Processed in 0.187500 second(s), 27 queries , Gzip On.

    深圳市墨知创新科技有限公司

    地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

    快速回复 返回顶部 返回列表