Sunteți pe pagina 1din 9

SKAA3413

TEST 1

SEM 02-2014/15

TEST 1
SEMESTER 2, SESSION 2014/2015
COURSE CODE

SKAA3413

COURSE

COMPUTER PROGRAMMING

PROGRAMME

SKAW

DURATION

1 HOUR 30 MINUTES

DATE

MAY 2015

INSTRUCTION TO CANDIDATES:
1. ANSWER ALL QUESTIONS.

NAME
STUDENT ID
SECTION
LECTURER

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

SKAA3413

Q1

a)

TEST 1

SEM 02-2014/15

Write MATLAB statements for the following arithmatic expressions. Where k,


b, h and r are all scalar variables, and

i)

is

22
7 .

1 3
r
3

k=

r 2 +4 bh

ii)

k=

iii
)

k=b+

2 rh
3 b 2 r
2r 3
(10 marks)

b)

If a, b, c and d is given as below.


a=3

b = [3 4 1]

c = [2 5 0]

d = [1 2 ; 3 4; 0 6]

Mark a cross X aginst each of the invalid MATLAB statement below.


i)

e = b * c

ii)

e = a * b * c

iii
)

e = b + c ^ 2

iv
)

e = a * c * d
(5 marks)

c)

Determine the return value of each of the following statement.


Statement

i)

10 > 30 / 2

ii)

(4<5)= =(4~=5)

iii
)

8 ^ 2 < 16 && 5 > 2

Return Value

SKAA3413

TEST 1

iv)

SEM 02-2014/15

4 ^ 2 <= 16 && 5 <= 5


(5 marks)

Q2

a)

Given below is a scalar a, vectors b and c, and a matrix d;


a=3
0 6]

b = [3 4 1]

c = [2 5 0]

d = [1 2 ; 3 4;

Write the shortest MATLAB element-by-element operation for each of the


following equation in the right column.
i)

q = c2ba

q =

ii)

2
a

r =

s =a-d2

s =

iii
)

r=

(6 marks)

b) The value of x, y and z in the following simultaneous equations can be solved using
linear algebra c=k-1d or c=inv(k)d. Where c is a column vector containing the
values of x, y and z.
x+2y-z -2=0

3y 2z +7 =0

3x-y+2z -5=0

Write down the k and d matrix/vector to find c, then write a statement to


determine c.
k = ..................................................................................................
d = ...................................................................................................
c = ..................................................................................................
(6 marks)

c) Write MATLAB statement for each of the following.


i) create matrix f,
ii) create vector g by adding rows 2 and 3 of matrix f ,
iii) create a new 3 by 4 matrix h, where the first and last row is identical to
matrix f, while the second row consist of vector g.
iv) Modify h by deleting the first and the last row.

2
f = 1

5
6

3
3

i) f = .........................................................
8
g = ..........................................................
2 ii)

SKAA3413

TEST 1

8
5

0
4

2
2

5
9

SEM 02-2014/15

iii)

h = ..........................................................

iv)

h ..........................................................
h .........................................................
(8 marks)

Q3

a)

Table Q3 shows a MATLAB program consisting nested if-else. If the input of y is


(i) 1200, (ii) 1990 and (iii) 2000, fill in the variable values after each statement has been
executed.

MATLAB script

Variable
name

Variable values
(i)

y=input('Enter value of y ; ');

y=

if y < 1582

true/false

disp('y must be GREATER than 1582')

1200

(ii)

(iii)

199
0

2000

*(Write the answer below this table)

else
c1=rem(y,400);

c1 =

c2=rem(y,100);

c2 =

c3=rem(y,4);

c3 =

if c1==0 && c2==0

true/false

r='CFRMD';

r=

else
r='NTSURE';

r=

end
fprintf(' y is %s\n',r)

*(Write the answer below this table)

end
*Answer printed in Command Window

(i)

(ii)

(iii)

(20 marks)

SKAA3413

Q4

TEST 1

SEM 02-2014/15

Figure Q4(a) shows a simply supported beam; over-hanged over the left support. It is
loaded by a uniformly distributed load the whole length of the beam.
Write a MATLAB program (script) for the problem stated below.
a) Determine the value of the maximum bending moment and its location.
(30 marks)

b) Plot the bending moment diagram (BMD). Sample for the BMD plotted in
MATLAB Figure Window is shown in Figure Q4(b).
(10 marks)
The general equation to solve the problem is given in Table Q4(a) and sample
result as shown in Table Q4(b).

Figure Q4(a)

Figure Q4(b)

Table Q4(a)

Reactions:
rb =

Basic Bending moment:


Region OA : -qx2/2

q ( a+l ) a+l
(
a)
l
2

Region AB : - qx2/2 + ra (x-a)

ra = q(a+l) - rb

Table Q4(b)
Left overhang length 2.0
Support distance 5.0
Load intensity 8.0
Left support reaction, Ra = 39.20
Right support reaction, Rb = 16.80
Maximum BM is 17.64 at x= 4.9

SKAA3413

TEST 1

SEM 02-2014/15

SKAA3413

TEST 1

Write the MATLAB program for the above problem in the table below.

SEM 02-2014/15

SKAA3413

TEST 1

SEM 02-2014/15

SKAA3413

TEST 1

SEM 02-2014/15

S-ar putea să vă placă și