forked from divyanshusrivastava/dsp-matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sep5_exercise4.m
46 lines (32 loc) · 1.02 KB
/
sep5_exercise4.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
clear all;
clc;
plotter = zeros(6,16);
plotter(1,:) = 0:15;
plotter(2,:) = 1;
plotter(3,11:16) = 1;
plotter(4,:) = plotter(2,:) - plotter(3,:);
plotter(5,:) = (plotter(4,:) + fliplr(plotter(4,:)))/2;
plotter(6,:) = (plotter(4,:) - fliplr(plotter(4,:)))/2;
subplot(3,2,1),stem(plotter(1,:),plotter(2,:));
title('u(n)');
subplot(3,2,2),stem(plotter(1,:),plotter(3,:));
title('u(n-10)');
subplot(3,2,3:4,'align'),stem(plotter(1,:),plotter(4,:));
title('u(n) - u(n-10)');
subplot(3,2,5),stem(plotter(1,:),plotter(5,:));
title('EVEN PART');
subplot(3,2,6),stem(plotter(1,:),plotter(6,:));
title('ODD PART');
range = -15:15;
plotter2 = zeros(4,31);
plotter2(1,:) = range;
plotter2(2,16:31) = plotter(4,:);
plotter2(3,:) = (plotter2(2,:) + fliplr(plotter2(2,:)))/2;
plotter2(4,:) = (plotter2(2,:) - fliplr(plotter2(2,:)))/2;
figure(2)
subplot(311),stem(plotter2(1,:),plotter2(2,:));
title('u(n)-u(n-10)');
subplot(312),stem(plotter2(1,:),plotter2(3,:));
title('EVEN PART');
subplot(313),stem(plotter2(1,:),plotter2(4,:));
title('ODD PART');