Download presentation

Presentation is loading. Please wait.

Published byRaquel Piercy Modified about 1 year ago

1
function[y,n]=sigadd(x1,n1,x2,n2) %n1:index vector for x1 %n2:index vector for x2 n=min(min(n1),min(n2)):max(max(n1),max(n2));%duration of y(n) y1=zeros(1,length(n)); y2=y1; %initialization y1(find((n>=min(n1))&(n<=max(n1))))=x1; %x1 with duration of y y2(find((n>=min(n2))&(n<=max(n2))))=x2; %x2 with duration of y y=y1+y2;

2
>> x1=[1 1 1]; >> n1=[2 3 4]; >> x2=[2 2 2]; >> n2=[4 5 6]; >> [y,n]=sigadd(x1,n1,x2,n2) y = n =

3
function[y,n]=sigmult(x1,n1,x2,n2) %n1:index vector for x1 %n2:index vector for x2 n=min(min(n1),min(n2)):max(max(n1),max(n2));%duration of y(n) y1=zeros(1,length(n)); y2=y1; %initialization y1(find((n>=min(n1))&(n<=max(n1))))=x1; %x1 with duration of y y2(find((n>=min(n2))&(n<=max(n2))))=x2; %x2 with duration of y y=y1.*y2;

4
>> [y,n]=sigmult(x1,n1,x2,n2) y = n =

5
function [y,n]=sigshift(x,m,k) %implements y(n)=x(n-k) %m: index vector for x n=m+k;y=x; >> xn=0:20;x=stepseq(0,0,20); >> [y,yn]=sigshift(x,xn,5); >> subplot(2,1,1),stem(xn,x),title('u(n)'),axis([0 30,0,1]) >> subplot(2,1,2),stem(yn,y),title('u(n-5)'),axis([0 30,0,1])

6
function [y,n]=sigfold(x,n) %implements y(n)=x(-n) y=fliplr(x); n=-fliplr(n); >> xn=0:6;x=rampseq(0,0,6); >> [y,yn]=sigfold(x,xn); >> subplot(2,1,1),stem(xn,x),title('ur(n)'),axis([-10,10,0,6]) >> subplot(2,1,2),stem(yn,y),title('ur(-n)'),axis([-10,10,0,6])

7
>> n=-2:10;x=[1:7, 6:-1:1]; >> [x11,n11]=sigfold(x,n);[x11,n11]=sigshift(x11,n11,3); >>[x12,n12]=sigshift(x,n,2);[x12,n12]=sigmult(x,n,x12,n12); >> [x1,n1]=sigadd(x11,n11,x12,n12); >> stem(n1,x1)

8
N=7 >> x=[ ]; >> n=-6:14; >> stem(n,[x x x])

9
function [xe,xo,l]=evenodd(x,n) %Real signal decomposition into even and odd parts if any(imag(x)~=0) error('x is not a real signal') end [y,m]=sigfold(x,n); [xe,l]=sigadd(x,n,y,m);xe=xe/2; [xo]=sigadd(x,n,-y,m);xo=xo/2;

10
>> n=[0:10];x=stepseq(0,0,10)-stepseq(10,0,10); >> [xe,xo,m]=evenodd(x,n); >> subplot(2,2,1); stem(n,x);title('X(n)'); axis([-10,10,0,1.2]) >> subplot(2,2,2); stem(m,xe);title('Xe(n)'); axis([-10,10,0,1.2]) >> subplot(2,2,4); stem(m,xo);title('Xo(n)'); axis([-10,10,-0.6,0.6])

11
>> nx=-3:3;X=[1:7];[Y,ny]=sigfold(X,nx); >> [Y1,ny1]=sigshift(Y,ny,1); >> [X1,nx1]=sigshift(X,nx,1);[Y2,ny2]=sigfold(X1,nx1); >> subplot(2,1,1); stem(ny1,Y1); title('y(n-1)');axis([-4,4,0,8]) >> subplot(2,1,2); stem(ny2,Y2); title('y(n,1)');axis([-4,4,0,8]) y(n)=x(-n) is TIME VARIANT

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google