Test 1 December 2016, questions PDF

Title Test 1 December 2016, questions
Course COMPUTER PROGRAMMING
Institution Universiti Teknologi Malaysia
Pages 11
File Size 586.3 KB
File Type PDF
Total Downloads 266
Total Views 319

Summary

SKAA 3413 TEST 1 SEM TEST 1 SEMESTER 1, SESSION COURSE CODE : SKAA 3413 COURSE : COMPUTER PROGRAMMING PROGRAMME : SKAW DURATION : TWO (2) HOURS ONLY DATE : OCTOBER 2017 INSTRUCTION TO CANDIDATES: 1. ANSWER ALL QUESTIONS. 2. ANSWER EACH QUESTION IN THE SPACE PROVIDED. Question NAME Marks Q1 STUDENT I...


Description

TEST 1 SEMESTER 1, SESSION 2016/2017 COURSE CODE

:

SKAA 3413

COURSE

:

COMPUTER PROGRAMMING

PROGRAMME

:

SKAW

DURATION

:

TWO (2) HOURS ONLY

DATE

:

OCTOBER 2017

INSTRUCTION TO CANDIDATES: 1. ANSWER ALL QUESTIONS. 2. ANSWER EACH QUESTION IN THE SPACE PROVIDED.

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 eleven (11) printed pages only.

1

SKAA 3413

Q1 a)

TEST 1 (30%)

SEM 01-2016/17

Please answer the following questions.

i)

Explain the two most important steps of Program Development Cycle (PDC) that are used in translating a given problem into a program code.

ii)

If a = [3 6 8;11 4 5], state whether each of the following statements is valid or invalid. MATLAB Statement

Valid/Invalid

a(1,2) = [ ] a(1,2) = 2

iii)

What is the use of the Editor Window and Figure Window in MATLAB?

iv)

How can we clear the content of the Command Window and Workspace Window?

(8 marks)

2

SKAA 3413

TEST 1 (30%)

SEM 01-2016/17

b) Please answer the following questions: Question i)

Answer

Using colon operator, create matrix A consisting of the following elements: 3 15 40

4 30 30

5 45 20

A =

6 60 10 B =

and then create matrix B from matrix A as shown below: 40

30

45

60

ii) Write the value of matrix C for the following statements:

C =

A = 2*(linspace(2,5,4)) A(2,1:end) = [5:2:12] C = A./2

iii) Provide the value of D for the following statements

D =

A = [10 -32 50;6 20 -40; 8 4 1] B = [2 4 5] D = [(3*B)' A(1:end,2)]

(10 marks)

3

SKAA 3413

TEST 1 (30%)

SEM 01-2016/17

c) Please write the scripts for the algorithms below: Algorithm

Script

i) Given variables r = [10 20 30], b = [25 50 75], h = [50 100 150] and π = 3.14, calculate the moment of inertia for a composite Ix using the following equation:

ii) Create matrix X with the appropriate value of π to 2π radian with the interval of π/10. Calculate y and dy based on the equations below:

Calculate the mean value of y. Plot both functions (y and dy) versus x on the same axes. (12 marks)

4

SKAA 3413

TEST 1 (30%)

SEM 01-2016/17

Q2 a) Figure Q2(a) shows a simple truss ABC which is loaded by 10 kN force as shown. A set of linear equations obtained from the joint equilibrium for the system is as listed in Figure Q2(b), where f1 - f6 are reactions and member internal forces as shown by the circle in Figure Q2(a). These equations can be solved using MATLAB by creating relevant arrays and applying WX=Y, where W is a square matrix and X and Y are column vectors. f1 =0 f2 + f3 =0 -f3 - 0.6f4 = 0 -0.8f4 – 10 = 0 0.6f4 + f6 =0 0.8f4 + f5 = 0

Figure Q2(a)

Figure Q2(b)

(i) Write the content of arrays W, X and Y in the space provided below. (7 marks)

W=

X=

Y=

(ii) Write MATLAB statements to create matrix W, vector Y and an expression to solve X. (3 marks) W = _______________________________________________________________ Y = ________________________________________________________________ X = ________________________________________________________________

b) If the size of matrix M is 6 x 100, write MATLAB statement to: (6 marks) (i) Add the second and third rows of M and store in P. P= _____________________ (ii) Delete the first row of M.

___________________________

(iii)Add a new last row to M such that all are 1’s.

___________________________

(iv)Delete the entire columns 10 to 20 of M.

___________________________

(v) Determine the size of M?

___________________________

5

SKAA 3413

TEST 1 (30%)

SEM 01-2016/17

c) Table Q2(a) shows a MATLAB script. Table Q2(a) 1

f=[400 200];

2

a=[60 30];

3

fx=f.*cosd(a);

4

fy=f.*sind(a);

5

tfx=sum(fx);

6

tfy=sum(fy);

7

fr=sqrt(tfx^2+tfy^2);

8

frang=atand(tfy/tfx);

9

mat=[f;a;fx;fy];

10

disp('SUMMARY')

11

fprintf('Force

12

fprintf('%6.2f\t%6.2f\t%6.2f\t%6.2f\n',mat)

13

fprintf('Total Fx is '),fprintf('%.1f',tfx)

14

fprintf('Total Fy is '),fprintf('%.1f',tfy)

15

fprintf('\n\nThe FR is %5.1f KN\n at %4.1f deg.\n',fr,frang)

Angle

Fx

Fy\n')

If the script is executed; (i) Write down the return values for the following variables: (6 marks) fx =

_________________________________________________________

fy =

_________________________________________________________

tfx =

_________________________________________________________

tfy =

_________________________________________________________

fr =

_________________________________________________________

frang = ________________________________________________________

6

SKAA 3413

TEST 1 (30%)

SEM 01-2016/17

(ii) Write down in the box below what would be displayed by statement lines 1015. (6 marks)

(iii) Replace statement lines 11-15 of Table Q2(a), so that it would display the result as shown in Table Q2(b) in the box below. (6 marks) 11 12 .. .. .. .. .. ..

Table Q2(b) Force Angle Comp.Fx Comp.Fy

   

   

The resultant is  at  radians

7

Note:  ‘s,  ‘s,  ‘s and  ‘s are the numerical content of vectors f, a, fx and fy, respectively.  and  are the numerical values of variables fr and frang.

SKAA 3413

TEST 1 (30%)

SEM 01-2016/17

d) Table Q2(c) below shows a MATLAB scripts. If the script is executed: i) Fill in spaces provided with he current values of variables, and ii) If Table Q2(d) represents the Command Window, write down what would be displayed. The initial variable values are listed below: w= 220; c = 20; A = 2500;

d = 25 (10 marks)

Table Q2(c) MATLAB SCRIPT

Variable name

teks='GOOD TRY'

teks=

smax=4*d

smax=

n=round(4*A/pi/d^2)

n=

z=n*d s=round((w-2*c-z)/(n-1))

z=

Variable value

s= ans=

if s>d && s 2.0 13. Display the output in the format as shown in Table Q3(a).

Answer for Q3 clc, clear %Input dimensions of retaining wall

%Completing the other dimensions (wall, base and soil)

%Assigning values into variables

10

SKAA 3413

TEST 1 (30%)

SEM 01-2016/17

Answer for Q3 (cont’d) %Calculations

%Display results

(30 marks)

11...


Similar Free PDFs