Solution - Practice 2 A) Relational/Logical Exercises: Refer To Matlab
Solution - Practice 2 A) Relational/Logical Exercises: Refer To Matlab
School of Engineering
SOLUTION PRACTICE 2
A) Relational/Logical exercises
Refer to Matlab
B) Control Flow-IF-block exercises
1. n = 7
gives m = 8
n = 9
gives m = -1
n = -10 gives m = -11
2. z
z
z
z
=
=
=
=
1
9
60
200
gives
gives
gives
gives
w
w
w
w
=
=
=
=
2
0
sqrt(60)
200
3. T = 50 gives h = 0
T = 15 gives h = 31
T = 0 gives h = 1
4. x
x
x
x
=
=
=
=
-1
5
30
100
gives
gives
gives
gives
y
y
y
y
=
=
=
=
500
20
120
500
Page 1 of 4
Taylors University
School of Engineering
20000
35200
100000
200000
0.0040
0.0031
0.0020
0.0018
Q1b)
>> p= v.*v
p=
14400
>> z=p./r
z=
1.4400
6400
0.3200
12100
0.3438
40000
0.4000
122500
0.6125
Page 2 of 4
Taylors University
School of Engineering
Q2)
7.5000
Taylors University
School of Engineering
2.0000
0.5000
0.7500
1.5000
3.0000
>> W = force.*distance
W=
800
275
525
750
1800
Q3b)
>> z=sum(W)
z=
4150
Page 4 of 4