summaryrefslogtreecommitdiff
path: root/911/CH9/EX9.5.b/ex_9_5_b.sce
blob: 2dc346d5a2231a7c5412f16aad889ed23b509c9a (plain)
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
//example 9.5(b)//
clc
//clears the screen//
clear
//clears all existing variables//
close
c = [0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 ];
//taking the values for a mod - counter
q = [0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 ];
a = [0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 ];
b = [0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 ];
y1=q;
y2=a;
y3=b;
y11p =1;
y22p =1;
y33p =1;
y44p =1;
cp =1;
yf1p =1;
for i =1:17
    // making arrays to draw the output
if y1(i)==1 then
for o =1:100
y11 ( y11p )=1;
y11p = y11p +1;
end
else
for o =1:100
y11 ( y11p )=0;
y11p = y11p +1;
end
end
if y2(i)==1 then
for o =1:100
y21 ( y22p )=1;
y22p = y22p +1;
end
else
for o =1:100
y21 ( y22p )=0;
y22p = y22p +1;
end
end
if y3(i)==1 then
for o =1:100
y31 ( y33p )=1;
y33p = y33p +1;
end
else
for o =1:100
y31 ( y33p )=0;
y33p = y33p +1;
end
end
if c(i)==1 then
for o =1:100
c1(cp) =1;
cp=cp +1;
end
else
for o =1:100
c1(cp) =0;
cp=cp +1;
end
end
end
z =[2 2];
subplot (4 ,1 ,1);
//ploting the output
title ( ' Timing Diagram ' );
plot (c1);
plot (z);
ylabel ( 'C ' );
subplot (4 ,1 ,2);
plot (y11);
ylabel ( 'Q' );
plot (z);
subplot (4 ,1 ,3);
plot (y21);
ylabel ( 'A' );
plot (z);
subplot (4 ,1 ,4);
plot (z);
ylabel ( 'B ' );
plot (y31);