{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

E7+Sp2010+Assignment+2+Solutions-1

E7+Sp2010+Assignment+2+Solutions-1 - Answer Key Assignment...

Info icon This preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Answer Key Assignment 2 Feb 12, 2010 1 Assignment 2: Function by Restrictions Problem 1: Getting to Know Boolean Operators (20) 1.1) Matlab uses ‘1’ to denote a true statement, a ‘0’ for false statement. +1 1.2) Various Answers are ok. All Matlab outputs should equal 1 1.3) >> xor(or(and(1,0), xor(0,1)),1) ans = 0 +1 >> and(pi,1) ans = 1 +1 >> and(pi,0) ans = 0 +1 Ans to multiple choice: ii: Logical X Logical Logical +1 1.4) >> not(eq(a,b)) where a and b are elements +1 >> gt(10,5) ans = 1 +1 >> gt(5,10) ans = 0 +1 >> gt(10,5) +1 for using gt and getting an output of 1 ans = 1 >> lt(1,3) +1 for using lt ans = 1 >> eq(5,5) +1 for using eq ans = 1 >> ge(6,5) +1 for using ge ans = 1 >> le(3,5) +1 for using le ans = 1 >> ne(1,2) +1 for using ne ans = 1
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
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
Image of page 2
Answer Key Assignment 2 Feb 12, 2010 3 Sensor 3 = 1 if Residue13 and Residue23 = 1 0 if Residue13 or Residue23 = 0 " # $ 2.2) 2.3) ! " # = otherwise 0 tolerance exceed Residue13 and Residue12 both of s difference if 1 1 Sensor ! " # = otherwise 0 tolerance exceed is Residue23 and Residue12 both of s difference if 1 2 Sensor ! " # = otherwise 0 tolerance exceed is Residue23 and Residue13 both of s difference if 1 3 Sensor +1 myDiagnoser1.m +1 function output = myDiagnoser1(a) % NAME % DATE % myDiagnoser1: models triple redundancy. finds sensors errors given % residues. % input: three boolean expressions representing the residues of the sensors % output: boolean expressions representing whether the sensors are faulty % or not. 1 = faulty, 0 = not faulty %a{1} = Res12 %a{2} = Res23 %a{3} = Res13 output=[and(a(1),a(3)),and(a(1),a(2)),and(a(2),a(3))]; >> myDiagnoser1([1,1,0]) ans = 0 1 0 +2 >> myDiagnoser1([0,1,1]) ans = 0 0 1 +2 >> myDiagnoser1([1,0,1]) ans = 1 0 0 +2
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Answer Key Assignment 2 Feb 12, 2010 4 2.4) This question is worth three points total. There are two acceptable solutions due to a typo in the problem Problem 3: Programming Functions by Restriction (42) 3.1) myDiagnoser2 .m (proper solution) +1 myDiagnoser2 .m (alternative solution) +1 function Output = myDiagnoser2(a) % NAME % DATE % myDiagnoser2: finds faulty sensor (if any) given sensor inputs % input: three sensor inputs, numbers % output: boolean expressions whether the sensors are faulty or not.
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern