x2 n 1 y1 mydiffeqx1 y2 mydiffeqx2 y3 mydiffeqx1 2x2 a It is linear because y3

X2 n 1 y1 mydiffeqx1 y2 mydiffeqx2 y3 mydiffeqx1 2x2

This preview shows page 8 - 10 out of 10 pages.

x2 = (n == 1);y1 = mydiffeq(x1)'y2 = mydiffeq(x2)'y3 = mydiffeq(x1 + 2*x2)'% a) It is linear, because y3 = y1 + 2*y2% --> see plots belowclf; figure(1);plot(y1 + 2*y2, 'r');hold onplot(y3);xlabel('n')legend('y1 + 2*y2', 'y3')title('Lab 3,3a')print('-dpng','-r72','Lab 3,3a')% b) It is also time invariant. When the signal is delayed by 3 samples% the magnitude of the points of y remain constant (based on graph).delayedN = n + 3;
Background image
9delayedX = (n == 0);delayedY = mydiffeq(delayedX);equalSums = (sum(delayedY) == sum(Y));% This is also clear from the plots below:clf; figure(2);plot(Y, 'g');hold onplot(delayedY);xlabel('n')legend('y', 'y (delayed)')title('Lab 3,3b')print('-dpng','-r72','Lab 3,3b')% c) Impulse response of systemx = [1, zeros(1,100)];originalH = mydiffeq(x);clf; figure(3);stem(originalH)xlabel('n')ylabel('mydiffeq()')title('Lab 3,3c')print('-dpng','-r72','Lab 3,3c')% d) Output signals are same.n = -10:60;x = cos(pi * n / 8) .* ((n >= 0) - (n >= 50));y1 = conv(originalH, x);y2 = mydiffeq(x);clf; figure(4);subplot(2,1,1);stem(y1, 'g');xlim([0 120]);legend('conv(h, x)')xlabel('n')ylabel('conv(h, x)')title('Comparison of output signal using conv() and mydiffeq() - Lab 3,3d')subplot(2,1,2);stem(y2);xlim([0 120]);legend('mydiffeq(x)')xlabel('n')ylabel('mydiffeq(x)')print('-dpng','-r72','Lab 3,3d')% result of the convolution has a wider indp. axis than the one from% mydiffeq() - that relies on the length of the provided vector.% Aside from truncation, the signals are the same.% e) New difference equation: y(n) = x(n) + 2 x(n - 1)x = [1, zeros(1,100)];h = mydiffeq2(x);clf; figure(5);subplot(2,1,1);stem(originalH, 'g');xlim([0 40]);
Background image
10legend('Impulse response: d')xlabel('n')ylabel('Impulse response: d')title('Comparison of impulse responses from parts "d" and "e" - Lab 3,3e')subplot(2,1,2);stem(h);xlim([0 40]);legend('Impulse response: e')xlabel('n')ylabel('Impulse response: e')print('-dpng','-r72','Lab 3,3e')% impulse response from part e is given by h(1) = 1, h(2) = 2% and h(n) = 0 otherwise. This is similar to impulse response in part b% except the signal -0.95 * y(n-1) creates is killed.
Background image

You've reached the end of your free preview.

Want to read all 10 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture