School

York UniversityDepartment

Information TechnologyCourse Code

ITEC 2600Professor

Xiaofeng ZhouStudy Guide

QuizThis

**preview**shows half of the first page. to view the full**3 pages of the document.**ITEC2600 in-Class Exercises X.Zhou York University

ITEC 2600

Introduction to Analytical Programming

Lab Exercise ♯1

1. Explain what the following MATLAB commands produce, then excute the following expressions in

MATLAB command window.

(a) (3 ∗4) ∧2

(b) cos(pi)

(c) y= 10 ∧5

(d) x= 5

(e) exp(x)

2. Deﬁne variables a, b, c and das a= 15, b = 4, c = (3 ×a)/b, and d=a×b×c

b+c, then evaluate the

followings in MATLAB command window. (Note: the followings are mathematical expressions).

(a) b×d

a×(c+d)×eb+c

d×log2(a)−cos(d×c) + ab

(b) a3+c2

d−c+ln(|a+b−c−d|)

(c) √c×d×π−(a+b)2

log10 (a×c)

3. Think about what results would be of the following expressions, and then type them in MATLAB to

verify your answers.

3 == 5 + 2

'b'<'a'+ 1

10 >5+2

(10 >5) + 2

'c'== 'd'- 1 && 2 <4

'c'== 'd'- 1 || 2>4

xor('c'== 'd'- 1, 2 >4)

xor('c'== 'd'- 1, 2 <4)

10 >5>2

4. Create a row vector vec start from -10 to 10, by incremental 5, using colon operator. The do the

followings:

(a) Create a new vector sub vec by extract the last 3 elements of vector vec.

(b) Change the value of last element of vec such that the value of last element is the function sin of

itself.

1

###### You're Reading a Preview

Unlock to view full version