Test 1 May 2016, questions PDF

Title Test 1 May 2016, questions
Course COMPUTER PROGRAMMING
Institution Universiti Teknologi Malaysia
Pages 9
File Size 423.6 KB
File Type PDF
Total Downloads 4
Total Views 206

Summary

SKAA 3413 TEST 1 SEM TEST 1 SEMESTER 2, SESSION COURSE CODE : SKAA 3413 COURSE : COMPUTER PROGRAMMING PROGRAMME : SKAW DURATION : 1 HOUR 30 MINUTES DATE : APRIL 2016 INSTRUCTION TO CANDIDATES: 1. ANSWER ALL QUESTIONS. Question Marks NAME Q1 STUDENT ID Q2 SECTION Q3 LECTURER Total WARNING! Students c...


Description

TEST 1 SEMESTER 2, SESSION 2015/2016 COURSE CODE

:

SKAA 3413

COURSE

:

COMPUTER PROGRAMMING

PROGRAMME

:

SKAW

DURATION

:

1 HOUR 30 MINUTES

DATE

:

APRIL 2016

INSTRUCTION TO CANDIDATES: 1. ANSWER ALL QUESTIONS.

Question

Marks

NAME Q1 STUDENT ID

Q2

SECTION

Q3

LECTURER

Total

WARNING! Students caught copying/cheating during the examination will be liable for disciplinary actions and the faculty may recommend the student to be expelled from the study. This test question consists of nine (9) printed pages only.

1

SKAA 3413

Q1

a)

TEST 1 (30%)

SEM 02-2015/16

Please answer the following questions.

i)

Why does this MATLAB editor error message appear? Please explain.

ii)

Below is one of the errors in MATLAB programming, please explain the reason of the error and how to correct it. Error using _*_ Inner matrix dimensions must agree.

iii)

Explain the purpose of TEST AND DEBUG in programming.

(8 marks)

2

SKAA 3413

TEST 1 (30%)

SEM 02-2015/16

b) Please answer the following questions: Question i)

Answer

Using colon operator, create matrix M consisting of the following elements: 3 1.0 5

4 1.5 4

5 2.0 3

6 2.5 1

7 3.0 3

8 3.5 5

ii) Using linspace operator, create matrix N consisting of the following elements: 4 -3 2

6 -6 2

8 -9 2

10 -12 2

12 -15 2

iii) Provide the value of C for the following code. A = [1.1 -3.2 3.4;0.5 1.1 -0.6;1.3 2.5 7.5] B = [2.1 3.2] C = [B' A(2:end,1)]

(12 marks) c) Please write the scripts for the algorithms below: Algorithm

Script

i) Create variables a = [1 1 1], b = [3 4 5], c = [-3 -2 -1] and k = 2. Calculate the two values of x using the following equation: −𝑏 ± √𝑏2 − 𝑘 2 𝑎𝑐 𝑥= 𝑘𝑎 ii) Create matrix x with the value of 0 to 𝜋 radian with the interval of 𝜋/10. Calculate y1 and y2 based on the equation below: 𝑦1 = sin2(2𝑥) 𝑦2 = cos(𝑥 2 ) Plot both functions on the same axes.

(10 marks)

3

SKAA 3413

Q2

TEST 1 (30%)

SEM 02-2015/16

a) Table Q2(a) below shows an event procedure for the calculation of A, B, C and D variables. Fill in the A, B, C and D columns with the current values of the variables up to 2 decimal places when each statement in the procedure is executed as stated in MATLAB Workspace. Then, write the output of the program. Table Q2(a) Write the values of variables in the space below:

Line

Code

A

1

clc, clear

2

A = 2;

3

B = 5 / A + 27.5;

4

A = B ^ 2 / (A * 1.5 - 15) – (B * A / (3 ^ 2));

5

B = sqrt(abs(A) * 60 / 3) + 40 / (0.5 * A);

6

B = log((-2*B) \ A * 5 ^ 3);

7

C = round(rem(A,10));

8

if B > 50 && C < 20

9

D = B – 20;

10

D = (C + 20) ^ 2 – 10 / B; elseif ~ B > 50 && C < 20

13 14

C

elseif (B < 50) && C < 20

11 12

B

D = (C – 30) ^ 2 – 4 * B; else

15

D = (C – 25) ^ 2 – 20 * B;

16

end

17

if D < 950

18

fprintf ([‘Question too easy!\nResults:\n’ …

19

‘D = %-4.2f\nC = %-4.2f\nB = %-4.2f\n’ …

20

‘A = %-4.2f\n’], D,C,B,A)

21 22

else

23

fprintf ([‘Question too hard!\nResults:\n’ …

24

‘D = %-4.2f\nC = %-4.2f\nB = %-4.2f\n’ …

25

‘A = %-4.2f\n’], D,C,B,A)

26 27

end

(12 marks)

4

D

SKAA 3413

b)

TEST 1 (30%)

SEM 02-2015/16

Write the output of the MATLAB program below in the space provided. i)

clear, clc %Existing Data Runoff = [71 26 42 60 52]; SedimentYield = [30.5 21.3 11.2 318.7 423.5]; %Modified/Filtered Data TotalRunoff(3) = 19; SedimentYield(5) = 84.8; fprintf('The average runoff is %5.2f m3/s\n',mean(Runoff)) fprintf('The maximum sediment yield is %10.2f ton\n',max(SedimentYield))

Answer:

(4 marks) ii) clear, clc % This program is to determine moment of inertia for % triangular section b = [20 8]; h = [5 11]; Ix = b.*h.^3/36; disp(' b h Ix') fprintf('\t%4.0f\t%4.0f\t%5.1f\n',[b ; h; Ix])

Answer:

(4 marks)

5

SKAA 3413

c)

TEST 1 (30%)

SEM 02-2015/16

Table Q2(c) below shows the range values of water depth (Wd ) and flow conditions for the Semenyih watershed. Using if statement, convert this table into a MATLAB program so that it can select and display the flow condition for a given value of water depth accordingly. The program must validate that the water depth should not be less than 2.49, by displaying error message. Write your answer in the space provided. Table Q2(c): Condition of Water depth (m), Wd Ranges of Water Depth 2.49 – 4.49 4.49 – 6.09 > 6.09

Flow Condition Normal Alert Danger

clear, clc % water depth, Wd Wd = input('Enter the water depth: ');

(10 marks)

6

SKAA 3413

Q3

TEST 1 (30%)

SEM 02-2015/16

Table Q3(a) shows an over-hanged beam carrying a triangular distributed load. Write a MATLAB script to: (i) plot the shear force and bending moment diagrams [sample shown in Table Q3(b)] (ii) determine the absolute maximum shear force in the beam, (iii) determine the absolute maximum bending moment and its location, and (iv) display the output [sample shown in Table Q3(c)]. Table Q3(a )

Table Q3(b) SFD and BMD 40 30 20 10 BM & SF

l = a+b+c 2

Rb = Ra =

𝑞𝑙(3𝑙−𝑎) 2𝑏 𝑞𝑙 2

0 -10 -20 -30

- Rb

-40 -50

Shear force Bending Moment 0

2

4

6 Distance

8

10

12

Table Q3(c) – Sample Output THE BEAM Beam over-hanged at both ends Triangular load over the whole beam Load maximum intensity at RHS support a = 3.00 b = 5.80 c = 1.50 q = 20.0 Ra = 34.3 kN Rb = 68.7 kN Max.absolute shear is 40.85 kN. Max.absolute BM is 33.11 kNm at x = 5.95 m.

The equations for the bending moment and shear force for the three regions are given below, where x is the distance from the left end of the beam. Table Q3(d) Region a b c

Bending Moment Equation m1= m2= m3= -

Shear Force Equation

𝑞𝑥3 6𝑙 𝑞𝑥 3 6𝑙 𝑞𝑥3 6𝑙

s1 = + Ra(x-a)

s2 = -

+ Ra (x-a) + Rb (x-(a+b))

s3 = -

7

𝑞𝑥2 2𝑙 𝑞𝑥2 2𝑙 𝑞𝑥2 2𝑙

+ 𝑅𝑎 + 𝑅𝑎 + 𝑅𝑏

SKAA 3413

TEST 1 (30%)

SEM 02-2015/16

The steps listed in Table Q3(e) may be used to write the program. Table Q3(e) 1.

Get the input values using input function.

2.

Calculate the support reactions.

3.

Create three vectors; x1, x2 and x3 for regions a, b and c, respectively. For each of these vectors, use step of 0.05. All x values (x1, x2 and x3) are measured from the left end of the beam.

4.

Concatenate vectors x1, x2 and x3, to represent x for the whole beam.

5.

Calculate the shear force and bending moment for the regions separately and concatenate them. Use the equations in Table Q3(d).

6.

Plot the shear force and bending moment diagrams. Sample is shown in Table Q3(b).

7.

Determine the absolute maximum shear force. Use max and abs functions

8.

Determine the absolute maximum bending moment and its location. Use max and abs functions.

9.

Display the output in the format as shown in Table Q3(c).

Answer for Q3

8

SKAA 3413

TEST 1 (30%)

SEM 02-2015/16

Answer for Q3 (cont’d)

(40 marks)

9...


Similar Free PDFs