Code:
n = 0:10; x = 10* (0.8). ^ n; [Xec, Xoc] = Circevod (x); percent-----------------------------------------------------------------percent START a Percent-----------------------------------------------------------------figure (' Numbertitle ', ' off ', ' Name ', ' exameple5.10a x sequence ') set (GCF, ' Color ', ' white '); Subplot (3,1,1); Stem (n,x); Title (' Original sequence x (n) '); %axis ([0,10,-2.5,2.5]); Xlabel (' n '); Ylabel (' x (n) '); Grid On;subplot (3,1,2); Stem (n,xec); Title (' Circular-even component '); Axis ([ -0.5,10.5,-1,11]); Xlabel (' n '); Ylabel (' Xec (n) '); Grid On;subplot (3,1,3); Stem (N,XOC); Title (' Circular-odd component '); Axis ([ -0.5,10.5,-4,4]); Xlabel (' n '); Ylabel (' Xoc (n) '); Grid on;%%-----------------------------------------------------------------percent END a%%---------------- -------------------------------------------------%% ------------------------------------------------------------ -----percent START b%%-----------------------------------------------------------------x_dft = DFT (x,11); % DFT of xxec_dft = DFT (xec,11); XOC_DFT = DFT (xoc,11); % DFT of xec and xocrealx_dft = Real (X_DFT); IMAGX_DFT = Imag (X_DFT); MAGX_DFT = ABS (X_DFT (1:1:6)); PHAX_DFT = Angle (X_DFT (1:1:6)) *180/pi;realxec_dft = Real (XEC_DFT); IMAGXEC_DFT = Imag (XEC_DFT); MAGXEC_DFT = ABS (XEC_DFT (1:1:6)); PHAXEC_DFT = Angle (xec_dft) *180/pi;realxoc_dft = Real (XOC_DFT); IMAGXOC_DFT = Imag (XOC_DFT); MAGXOC_DFT = ABS (XOC_DFT (1:1:6)); PHAXOC_DFT = Angle (XOC_DFT) *180/pi;figure (' Numbertitle ', ' off ', ' Name ', ' exameple5.10b ') set (GCF, ' Color ', ' white '); Subplot (2,2,1); Stem (N,REALX_DFT); Title (' Real {dft[x (n)} '); Axis ([ -0.5,10.5,-5,50]); Xlabel (' K '); Grid On;subplot (2,2,2); Stem (N,IMAGX_DFT); Title (' Imag {dft[x (n)]} '); Axis ([ -0.5,10.5,-20,20]); Xlabel (' K '); Grid On;subplot (2,2,3); Stem (N,REALXEC_DFT); Title (' Real {dft[xec (n)} '); Axis ([ -0.5,10.5,-5,50]); Xlabel (' K '); Grid On;subplot (2,2,4); Stem (N,IMAGXOC_DFT); Title (' Imag {DFT[XOC (n)]} '); Axis ([-0.5,10.5,-20,20]); Xlabel (' K '); Grid on;figure (' Numbertitle ', ' off ', ' Name ', ' exameple5.10b X DFT info ') set (GCF, ' Color ', ' white '); Subplot (2,2,1); Stem (N,REALX_DFT); Title (' Real {dft[x (n)} '); Axis ([ -0.5,10.5,-5,50]); Xlabel (' K '); Grid On;subplot (2,2,2); Stem (N,IMAGX_DFT); Title (' Imag {dft[x (n)]} '); Axis ([ -0.5,10.5,-20,20]); Xlabel (' K '); Grid on;k = 0:1:5; W = 2*pi/10*k;subplot (2,2,3); Stem (W/PI,MAGX_DFT); Title (' Magnitude DTFT '); %axis ([ -0.5,10.5,-5,50]); Xlabel (' Frequency in \pi units '); Grid On;subplot (2,2,4); Stem (W/PI,PHAX_DFT); Title (' Angle {dft[x (n)]} '); %axis ([ -0.5,10.5,-20,20]); Xlabel (' Frequency in \pi units '); Grid on;%%-----------------------------------------------------------------percent END b%%-------------- ---------------------------------------------------
Operation Result:
By the See, Nature (5.34) established:
"DSP using MATLAB" Example Example5.10