text: DeGracia_Miguel_19481379_Lab5
  
  # DeGracia_Miguel_19481379_Lab5 - %matrix form as well...
  
  This preview shows pages 1–2. Sign up to view the full content.
  
  %% Miguel De Gracia. 19481379. Lab Assignment 5. Section 22 % %% Problem 1a % x=2; y=3; x x > y x < y x >= y x <= y x == y x ~= y %The problem returns a 1 if the statement is true, and a 0 if the statement %is false. % %% Problem 1b % y = [1 3; 5 2]; y x > y x < y x >= y x <= y x == y x ~= y all(y==x) any(y==x) find(y<=x) %In this case since y is now a matrix, it compares x to every element of y %and performs the same task as the previous problem. For all or any it does %so by comparing it according to each column.Find returns the indeces in %which the logical statement is true. % %% Problem 1c % x = [2 4; 5 1]; x x > y x < y x >= y x <= y x == y x ~= y all(y==x) any(y==x) find(y<=x) %Since both x and y are now matrices, it compares the elements and %evaluates the logical command at that element, returning an answer in
  
  This preview has intentionally blurred sections. Sign up to view the full version.
  
  View Full Document
  This is the end of the preview. Sign up to access the rest of the document.
  
  Unformatted text preview: %matrix form as well. % %% Problem 1d % a=1; b=0; c=1; a a | b a & b a | c & b (a | c) & b a & (c | b) ~a & c ~(a | b | c) %Evaluates the logical operators when | means or, & and. Compares the %statement and evaluates if the values are equal. % %% Problem 1e % 5 > 2+4|~2+5==5 %Evaluates the furthermost expression 5==5 which is true so it becomes a %one, then 2+1 is 3, then now the expression looks like 6|~3, which will %return a 1, and at the end 5>1 is true so the answer is now 1. % %% Problem 2 % f1(-8) f1(-3) f1(4) f1(17) f type f1 t %% Problem 3 % type poly_adder t %% Problem 3a % poly_adder([1 2 3],[2 1 3]) p %% Problem 3b % poly_adder([1 2 3 4],[1 0 4]) p %% Problem 3c % poly_adder([1 5],[3 2 1 5]) p %% Problem 4 %...
  View Full Document
  
  ## This note was uploaded on 02/18/2010 for the course ENGINEERIN 7 taught by Professor Patzek during the Spring '08 term at Berkeley.
  
  ### Page1 / 2
  
  DeGracia_Miguel_19481379_Lab5 - %matrix form as well...
  
  This preview shows document pages 1 - 2. Sign up to view the full document.
  
  View Full Document
  Ask a homework question - tutors are online