SLIDE 1
CPE0907311 COMPUTER CPE0907311 COMPUTER APPLICATIONS LAB APPLICATIONS LAB EXERC EXERCISE SHEET 5 SE SHEET 5
1 1
UNIVERSITY OF JORDAN UNIVERSITY OF JORDAN CO COMP MPUTER ENGI UTER ENGINEERIN NEERING DEPARTM G DEPARTMENT NT
Prepared by Dr. Iyad Jafar
STUD STUDY THE S Y THE SLIDES O IDES OF EXPERI EXPERIMENT 5 MENT 5 AND SOLV AND SOLVE THE FO E THE FOLLOW LLOWING ING PROB PROBLEMS LEMS BEFORE COMING TO THE LAB. BEFORE COMING TO THE LAB.
1.
- 1. Find the results of the following expressions by hand then use Matlab to check your results.
Expression Answer Z = 12 > 5 - 8
Z =
Z = 6 + 3 > 18
Z =
Z = 5 <= (2*2)
Z =
2.
- 2. Suppose that x = [10,-3,19,12] and y = [3,1,-1,-3]. Evaluate the following expressions by
hand then verify your answer by Matlab. Provide a brief explanation for each case. Expression Answer Z = (x < 6)
Z =
Z = (x~=y)
Z =
Z = (y<~x)
Z =
Z = x|y
Z =
3.
- 3. Given the arrays x and y in problem 2, use Matlab to find the indices of elements in y that are
greater or equal than their corresponding elements in array x. Then, use array addressing to extract the values of these elements. Command(s) Answer
4.
- 4. Write a function that accepts an array A in its arguments and returns the array B that is
computed from array A such that:
- a. Elements in A less than or equal to -2 are replaced by 30.
- b. Elements in A greater than -2 and less than 5 are replaced by 15.
- c. Elements greater than 5 are replaced by 5.