You are on page 1of 4

ENG3202 Computer Programming

Logical Functions

Assignment 5a

The following problems can be solved by writing commands in the Command


Window, or by writing a program in a script file and then executing the file.

Question 1

Evaluate the following expressions WITHOUT USING MATLAB first. Then, you
may check the answer with MATLAB.

a) 4 + 5 > 36 / 4

b) y = 3 x (2 > 10 / 20) + (3 > 5)2

c) y = 4 x 2 > 12/8 + 2 > 32

d) 5 x 5 – 4 x 7 < = ~ 2 x 5 – 2 + ~0

e) 0 & 21

f) ~ - 2 > - 1 & 11 > = ~ 0

g) 4 – 7 / 2 & 6 < 5 | - 3

h) 3 | - 1 & ~ 2 * - 3 | 0

Question 2

The maximum daily temperature (in °C) for Chicago and San Francisco during the
month of August 2009 are given in the vectors below (data taken from the U.S.
National Oceanic and Atmospheric Administration)

TCH = [ 24 25 30 30 26 27 23 32 33 30 27 28 30 31 32 32 28 29 27 26 23
21 23 26 28 22 19 22 21 19 19 ]

TSF = [ 21 20 21 23 22 22 21 24 29 31 23 29 24 20 26 24 20 20 23 22 26
20 20 21 22 21 32 35 32 19 21 ]

Write a program in a script file to answer the following:

a) Calculate the average temperature for the month in each city.


b) How many days was the temperature above the average in each city?
c) How many days, and on which dates in the month, was the temperature in San
Francisco lower than the temperature in Chicago?
d) How many days, and on which dates in the month, was the temperature the same
in both cities?
Mathematical Operations with Array

Assignment 5b

Question 3

Question 4

Question 5
Question 6

Question 7
Question 8

Question 9

You might also like