0% found this document useful (0 votes)
28 views4 pages

Solution - Practice 2 A) Relational/Logical Exercises: Refer To Matlab

This document contains solutions to practice problems for a computing applications course taught by Dr. Thein Chung Ket at Taylor's University School of Engineering. It includes solutions to relational/logical exercises using MATLAB as well as control flow exercises using IF blocks and loop constructs. It also solves questions involving calculating speed from distance and time, power from force and distance, and summing the total work done.

Uploaded by

Nbl Klf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views4 pages

Solution - Practice 2 A) Relational/Logical Exercises: Refer To Matlab

This document contains solutions to practice problems for a computing applications course taught by Dr. Thein Chung Ket at Taylor's University School of Engineering. It includes solutions to relational/logical exercises using MATLAB as well as control flow exercises using IF blocks and loop constructs. It also solves questions involving calculating speed from distance and time, power from force and distance, and summing the total work done.

Uploaded by

Nbl Klf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Taylors University

School of Engineering

Computing Applications for Engineers


(ENG2314)

Dr Thein Chung Ket

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

In this last exercise, y = 4x for any input! Relational operations


are subject to precedence and ordering just as arithmetical
operations. The logical phrase a < x < b should be rendered as
the compound logical expression ((a < x) & (x < b)) in MATLAB.
5.

Page 1 of 4

Taylors University
School of Engineering

Computing Applications for Engineers


(ENG2314)

C) Loop constructs: for and while

D) Solve the following questions


Q1a)
r=
10000

20000

35200

100000

200000

>> v=[120 80 110 200 350]


v=
120 80 110 200 350
>> v./r
ans =
0.0120

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

Dr Thein Chung Ket

Taylors University
School of Engineering

Computing Applications for Engineers


(ENG2314)

Q2)

>> distance = [550 430 480 530 370]


distance =
550 430 480 530 370
>> time = [10.3 8.2 9.1 10.1 7.5]
time =
10.3000 8.2000 9.1000 10.1000

7.5000

>> speed = distance./time


speed =
53.3981 52.4390 52.7473 52.4752 49.3333
Q3a)
> force = [400 550 700 500 600]
force =
400 550 700 500 600
>> distance = [2 0.5 0.75 1.5 3]
distance =
Page 3 of 4

Dr Thein Chung Ket

Taylors University
School of Engineering

2.0000

0.5000

Computing Applications for Engineers


(ENG2314)

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

Dr Thein Chung Ket

You might also like