Answer Key
Assignment 2
Feb 12, 2010
2
1.5)
>> y2 = ‘aa’
+1
1.6)
1.7)
a)
>> and(le(x^2+y^2,2),or(and(or(le(x,-1),ge(x,1)),and(ge(y,-1),le(y,1))),and(or(le(y,-
1),ge(y,1)),and(ge(x,-1),le(x,1)))))
+1
b)
Right is the correct answer
+1 (picture not required)
Problem 2: Modeling Sensor Fault Detection
(16)
2.1)
+1
Sensor
1
=
1
if Residue12
and Residue13
=
1
0
if Residue12
or Residue13
=
0
"
#
$
Sensor
2
=
1
if Residue12
and Residue23
=
1
0
if Residue12
or Residue23
=
0
"
#
$
myGates.m
+1
function
Output=myGates(a)
% myGates: takes in 5 boolean inputs and returns an output modeled after
% the figure in Assignment 3
% inputs: input1 to input5, boolean statements
% outputs: boolean statement out
Output = not(and(or(xor(a{1},a{2}),a{3}),and(a{4},a{5})));
>> myGates({1,1,0,1,1})
ans =
1
+1
>> myGates({1,1,1,0,1})
ans =
1
+1