>> n=0:3 n = 0 1 2 3 >> mod(n-2,4) ans = 2 3 0 1 >> x=1:4 x =

14
>> n=0:3 n = 0 1 2 3 >> mod(n-2,4) ans = 2 3 0 1 >> x=1:4 x = 1 2 3 4 >> x(mod(n-2,4)+1) ans = 3 4 1 2

description

>> n=0:3 n = 0 1 2 3 >> mod(n-2,4) ans = 2 3 0 1 >> x=1:4 x = 1 2 3 4 >> x(mod(n-2,4)+1) ans = 3 4 1 2. >> n=0:10; x=10*(0.8).^n; >> y=x(mod(-n,11)+1); - PowerPoint PPT Presentation

Transcript of >> n=0:3 n = 0 1 2 3 >> mod(n-2,4) ans = 2 3 0 1 >> x=1:4 x =

Page 1: >> n=0:3 n =      0     1     2     3 >> mod(n-2,4) ans =      2     3     0     1 >> x=1:4 x =

>> n=0:3

n =

0 1 2 3

>> mod(n-2,4)

ans =

2 3 0 1>> x=1:4

x =

1 2 3 4

>> x(mod(n-2,4)+1)

ans =

3 4 1 2

Page 2: >> n=0:3 n =      0     1     2     3 >> mod(n-2,4) ans =      2     3     0     1 >> x=1:4 x =

>> n=0:10; x=10*(0.8).^n; >> y=x(mod(-n,11)+1);>> subplot(2,1,1);stem(n,x); axis([-1 11 0 11]);title('Original sequence')>> subplot(2,1,2);stem(n,y); axis([-1 11 0 11]);title('Circularly folded sequence')

Page 3: >> n=0:3 n =      0     1     2     3 >> mod(n-2,4) ans =      2     3     0     1 >> x=1:4 x =

>> X=dft(x',11);Y=dft(y',11);>> subplot(2,2,1);stem(n,real(X));title('Real[DFT[x(n)]]');>> subplot(2,2,2);stem(n,imag(X));title('Imag[DFT[x(n)]]');>> subplot(2,2,3);stem(n,real(Y));title('real[DFT[x((-n))11]]');>> subplot(2,2,4);stem(n,imag(Y));title('imag[DFT[x((-n))11]]');

Page 4: >> n=0:3 n =      0     1     2     3 >> mod(n-2,4) ans =      2     3     0     1 >> x=1:4 x =

function [xec, xoc]=circevod(x)% real-value signal decomposition into circular-even %and circular-odd parts if any(imag(x)~=0) error('x is not a real sequence')end N=length(x); n=0:(N-1);xec=0.5*(x+x(mod(-n,N)+1));xoc=0.5*(x-x(mod(-n,N)+1));

Page 5: >> n=0:3 n =      0     1     2     3 >> mod(n-2,4) ans =      2     3     0     1 >> x=1:4 x =

>> n=0:10; x=10*(0.8).^n;>> [xec,xoc]=circevod(x);>> subplot(2,1,1); stem(n,xec);title('Circular-even component')>> subplot(2,1,2); stem(n,xoc);title('Circular-odd component')

Page 6: >> n=0:3 n =      0     1     2     3 >> mod(n-2,4) ans =      2     3     0     1 >> x=1:4 x =

>> X=dft(x',11); Xec=dft(xec',11);Xoc=dft(xoc',11);

>> Xec

Xec =

45.7050 10.1671 + 0.0000i 6.2575 + 0.0000i 5.4515 5.1827 - 0.0000i 5.0887 - 0.0000i 5.0887 - 0.0000i 5.1827 - 0.0000i 5.4515 - 0.0000i 6.2575 - 0.0000i 10.1671 - 0.0000i

>> Xoc

Xoc =

-0.0000 0.0000 -13.4479i 0.0000 - 6.8202i 0.0000 - 3.8755i 0.0000 - 2.0562i 0.0000 - 0.6489i 0.0000 + 0.6489i 0.0000 + 2.0562i -0.0000 + 3.8755i -0.0000 + 6.8202i -0.0000 +13.4479i

Page 7: >> n=0:3 n =      0     1     2     3 >> mod(n-2,4) ans =      2     3     0     1 >> x=1:4 x =

>> subplot(2,2,1);stem(n,real(X));title('Real[DFT[x(n)]]')>> subplot(2,2,2);stem(n,imag(X));title('Imag[DFT[x(n)]]')>> subplot(2,2,3);stem(n,real(Xec));title('DFT[xec(n)]')>> subplot(2,2,4);stem(n,imag(Xoc));title('Imag[DFT[xoc(n)]]')

Page 8: >> n=0:3 n =      0     1     2     3 >> mod(n-2,4) ans =      2     3     0     1 >> x=1:4 x =

>> n=0:10; x=10*(0.8).^n; y=cirshift(x,6,15);>> n=0:14; x=[x,zeros(1,4)];>> subplot(2,1,1); stem(n,x);title('x(n)')>> subplot(2,1,2); stem(n,y);title('x((n-6))15')

Page 9: >> n=0:3 n =      0     1     2     3 >> mod(n-2,4) ans =      2     3     0     1 >> x=1:4 x =

>> X=dft(x',15);>> wn=exp(-j*2*pi/15);>> wn.^(6*[0:14]').*X

ans =

45.7050 -22.6391 + 7.9023i 13.4175 + 5.1388i -3.4939 - 8.4318i -1.8380 + 6.6090i 5.7729 - 3.3882i -5.7632 - 2.4191i 1.7576 + 4.9755i 1.7576 - 4.9755i -5.7632 + 2.4191i 5.7729 + 3.3882i -1.8380 - 6.6090i -3.4939 + 8.4318i 13.4175 - 5.1388i -22.6391 - 7.9023i

>> Y=dft(y',15)

Y =

45.7050 -22.6391 + 7.9023i 13.4175 + 5.1388i -3.4939 - 8.4318i -1.8380 + 6.6090i 5.7729 - 3.3882i -5.7632 - 2.4191i 1.7576 + 4.9755i 1.7576 - 4.9755i -5.7632 + 2.4191i 5.7729 + 3.3882i -1.8380 - 6.6090i -3.4939 + 8.4318i 13.4175 - 5.1388i -22.6391 - 7.9023i

Page 10: >> n=0:3 n =      0     1     2     3 >> mod(n-2,4) ans =      2     3     0     1 >> x=1:4 x =

>> n=0:10; x=10*(0.8).^n;>> wn=exp(-j*2*pi/11);dft(wn.^(-4*(0:10)').*x',11)

ans =

5.1827 + 2.0562i 5.4515 + 3.8755i 6.2575 + 6.8202i 10.1671 +13.4479i 45.7050 + 0.0000i 10.1671 -13.4479i 6.2575 - 6.8202i 5.4515 - 3.8755i 5.1827 - 2.0562i 5.0887 - 0.6489i 5.0887 + 0.6489i

>>X=dft(x',11);cirshift(X,4,11)

ans =

5.1827 + 2.0562i 5.4515 + 3.8755i 6.2575 + 6.8202i 10.1671 +13.4479i 45.7050 10.1671 -13.4479i 6.2575 - 6.8202i 5.4515 - 3.8755i 5.1827 - 2.0562i 5.0887 - 0.6489i 5.0887 + 0.6489i

Page 11: >> n=0:3 n =      0     1     2     3 >> mod(n-2,4) ans =      2     3     0     1 >> x=1:4 x =

function y=cirshift(x,m,N)%circular shift y(n)=x((n-m)mod N) if length(x)>N error('N must be >= the length of x')end x=[x zeros(1, N-length(x))];n=[0:1:N-1];n=mod(n-m,N); y=x(n+1);

Page 12: >> n=0:3 n =      0     1     2     3 >> mod(n-2,4) ans =      2     3     0     1 >> x=1:4 x =

>> x1=[1 2 2 0];X1=dft(x1',4);>> x2=[1 2 3 4];X2=dft(x2',4);>> idft(X1.*X2,4)

ans =

15.0000 + 0.0000i 12.0000 + 0.0000i 9.0000 - 0.0000i 14.0000 - 0.0000i

Page 13: >> n=0:3 n =      0     1     2     3 >> mod(n-2,4) ans =      2     3     0     1 >> x=1:4 x =

function y=circonvt(x1,x2,N)%N-point circular convolution between x1 and x2 (time domain) if length(x1)>N error('N must be >= the length of x1')end if length(x2)>N error('N must be >= the length of x2')end x1=[x1 zeros(1,N-length(x1))];x2=[x2 zeros(1,N-length(x2))];m=[0:1:N-1];x2=x2(mod(-m,N)+1); %circular foldingH=zeros(N,N);for n=1:1:N, H(n,:)=cirshift(x2,n-1,N);end y=H*x1';

Page 14: >> n=0:3 n =      0     1     2     3 >> mod(n-2,4) ans =      2     3     0     1 >> x=1:4 x =

>> x1=[1 2 2]; x2=[1 2 3 4]>> y=circonvt(x1,x2,4)

y =

15 12 9 14