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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
//Find the step response.
//Example 3.26<i>
clear;
close;
clc;
n=-5:.01:5;
for i=1:length(n)
if n(i)==2 then
del1(i)=1;
del2(i)=0;
elseif n(i)==3 then
del1(i)=0;del2(i)=1;
else
del1(i)=0;del2(i)=0;
end
x1(i)=del1(i)+del2(i);
if n(i)<0 then
x2(i)=0;
else
x2(i)=1;
end
end
y=convol(x1,x2);
//figure
f=scf(0);
plot(n,x1,'black');
xtitle('Delta function as input');
xs2jpg(0, 'problem39-plot-a.jpg');
//figure
f=scf(1);
plot(n,x2,'red');
xtitle('Unit function as input');
xs2jpg(1, 'problem39-plot-b.jpg');
//figure
f=scf(2);
n1=-10:.01:10;
plot(n1,y,'green');
xtitle('Step function as output');
xs2jpg(2, 'problem39-plot-c.jpg');
//Example 3.26 <ii>
//Find the step response.
clc;
clear;
close;
n=-5:.01:5;
a=6;
for i=1:length(n)
if n(i)<0 then
h(i)=0;x(i)=0;
else
h(i)=(-a)^n(i);
x(i)=1;
end
end
s=convol(h,x);
//figure
f=scf(0);
plot(n,h,'red');
xtitle('h(n)');
xs2jpg(0, 'problem40-plot-a.jpg');
//figure
f=scf(1);
plot(n,x,'green');
xtitle('x(n)');
xs2jpg(1, 'problem40-plot-b.jpg');
//figure
f=scf(2);
n1=-10:.01:10;
plot(n1,s,'blue');
xtitle('s(n)');
xs2jpg(2, 'problem40-plot-c.jpg');
//Example 3.26<iii>
//Find the step response of the system.
clc;
clear;
close;
n=-5:.01:5;
for i=1:length(n)
if n(i)<0 then
h(i)=0;x(i)=0;
else
h(i)=1;
x(i)=1;
end
end
s=convol(h,x);
//figure
f=scf(0);
plot(n,h,'black');
xtitle('h[n]');
xs2jpg(0, 'problem41-plot-a.jpg');
//figure
f=scf(1);
plot(n,x,'red');
xtitle('x[n]');
xs2jpg(1, 'problem41-plot-b.jpg');
//figure
f=scf(2);
n1=-10:.01:10;
plot(n1,s,'green');
xtitle('s[n]');
xs2jpg(2, 'problem41-plot-c.jpg');
//Example 3.26 <iv>
//Find the step response.
clc;
clear;
close;
n=-5:.01:5;
for i=1:length(n)
if n(i)<0 then
h(i)=0;x(i)=0;
else
h(i)=((1/2)^n(i))+((-(1/3))^n(i));
x(i)=1;
end
end
s=convol(h,x);
//figure
f=scf(0);
plot(n,h,'red');
xtitle('h(n)');
xs2jpg(0, 'problem42-plot-a.jpg');
//figure
f=scf(1);
plot(n,x,'green');
xtitle('x(n)');
xs2jpg(1, 'problem42-plot-b.jpg');
//figure
f=scf(2);
n1=-10:.01:10;
plot(n1,s,'blue');
xtitle('s(n)');
xs2jpg(2, 'problem42-plot-c.jpg');
|