Sie sind auf Seite 1von 6

NAME OF STUDENT:wan aida syahirah binti wan mohammad abdul rauf

GROUP:ec2216c1

DATE :

(STUDENTS ARE REQUIRED TO WRITE THEIR CODE AND ANSWERS IN THIS GIVEN BOX ANSWER
AND CONVERT IT TO PDF FORMAT)

CES 513/512 SUPPLEMENTARY LAB SHEET DOCUMENT (LAB 2)

PROBLEM FOR LAB 2

PROBLEM 1

Given a Table 1 of a data for the human population from the year of 1984 to 1996.

Year 1984 1986 1988 1990 1992 1994 1996


Population 127 130 136 145 158 178 211
(in million)

a) Create separate row matrix in MATLAB for storing the year and the population

>> year=[1984 1986 1988 1990 1992 1994 1996]

>> population=[127 130 136 145 158 178 211]

b) Create separate column matrix in MATLAB for storing the year and population

>> year'

>> population'

c) Using a constant spacing, write the same arrays in a) in MATLAB

>> year=1984:2:1996

d) Using MATLAB, compute the maximum, mean and the summation of the population

>>mea>> maximum=max(population)

>> summation=sum(population)

>> mean=mean(population)
PROBLEM 2

a) Create the following matrices using MATLAB


5 12
1 7
−3
𝐴=[ 2]
6 −10
3
11 5 3
𝐵=[ ]
2 6.54 1
7 14 1
𝐶 = [10 3 −2]
8 −5 9

>> A=[5 2 1;1 7 -3;6 -10 2/3]

>> B=[11 5 3;2 6.54 1]

>> C=[7 14 1;10 3 -2;8 -5 9]

b) Using MATLAB, compute A+C and C-A

>> E=C-A >> D=A+C

2.0000 12.0000 0 12.0000 16.0000 2.0000

9.0000 -4.0000 1.0000 11.0000 10.0000 -5.0000

2.0000 5.0000 8.3333 14.0000 -15.0000 9.6667

c) Using MATLAB, calculate 5B

>> F = 5*B

55.0000 25.0000 15.0000

10.0000 32.7000 5.0000

d) Using MATLAB, determine AB and BA


e) Using MATLAB, solve 3.2(A+C) and 3.2A + 3.2C

>> G=3.2*(A+C) >> H=3.2*A+3.2*C

38.4000 51.2000 6.4000 38.4000 51.2000 6.4000

35.2000 32.0000 -16.0000 35.2000 32.0000 -16.0000

44.8000 -48.0000 30.9333 44.8000 -48.0000 30.9333

f) Using MATLAB, determine AB, A-B and A+B

>> J=A-B

Matrix dimensions must agree.


>> I=A*B

>> K=A+B

Matrix dimensions must agree.

g) Add an identity matrix of same dimension with matrix A with matrix A

>> FF=eye(3)+A >> FFF=eye(size(A))+A


6.0000 2.0000 1.0000 6.0000 2.0000 1.0000
1.0000 8.0000 -3.0000 1.0000 8.0000 -3.0000
6.0000 -10.0000 1.6667 6.0000 -10.0000 1.6667

h) Multiply magic matrix with matrix C with MATLAB

>> A*C

63.0000 71.0000 10.0000

53.0000 50.0000 -40.0000

-52.6667 50.6667 32.0000


i) Perform multiplication, division, exponential elementwise operation on matrices A and C

>> A.*C

>> A./C

>> A.^C

PROBLEM 3

The axial force, Fi, in each of the 13 member pin connected truss, can be calculated by solving the
following system of 13 equations;

F2 +0.7071F1 =0

-F2 +F6 =0

F3 -2000 =0

F4 +0.6585F3 -0.7071 F1 =0

0.7071F1 +F4 +0.7526F3 +1000 =0

F7 +0.6585F8 –F4 =0

0.7526F8 +F9 +500 =0

F10 -0.6585F5 –F6 =0

F9 +0.7526F5 -4000=0

0.7071F11 –F7 =0

0.7071F11 +F12 +500 =0

F12 +0.7526F8 -2000 =0

F13 +0.7071F11 =0

a) Convert the simultaneous linear equations in form of [K]{x} = {D} in register [K] and {D}
matrix in the MATLAB script
>> K1=[0.7071 1 0 0 0 0 0 0 0 0 0 0 0]

>> K2=[0 -2 0 0 0 1 0 0 0 0 0 0 0]

>> K3=[0 0 1 0 0 0 0 0 0 0 0 0 0]

>> K4=[-0.7071 0 0.6585 1 0 0 0 0 0 0 0 0 0]

>> K5=[0 0 0 -4 0 0 1 0.6565 0 0 0 0 0]

>> K6=[0 0 0 -4 0 0 1 0.6565 0 0 0 0 0]

>> K7=[0 0 0 0 0 0 0 0.7526 1 0 0 0 0]

>> K8=[0 0 0 0 -0.6585 -1 0 0 0 1 0 0 0]

>> K9=[0 0 0 0 0.7526 0 0 0 1 0 0 0 0]

>> K10=[0 0 0 0 0 0 -1 0 0 0 0.7071 0 0]

>> K11=[0 0 0 0 0 0 0 0 0 0 0.7071 1 0]

>> K12=[0 0 0 0 0 0 0 0.7526 0 0 0 1 0]

>> K13=[0 0 0 0 0 0 0 0 0 0 0.7071 0 1]

>> D={0 0 2000 -1000 0 0 -500 0 4000 0 -500 2000 0}

>> K=[K1;K2;K3;K4;K5;K6;K7;K8;K9;K10;K11;K12;K13]

b) Find the inverse and the determinant of [K} using MATLAB script

>> K^(-1)

c) Determine the {x} by multiplying the inverse of [K} with {D} using MATLAB script

>> force=K inverse*D


d) With a sudden of architect changes, the RIGHT- hand side of the thirteen equation has been
changed from 0 kN to -2000 kN. Using MATLAB, solve for {x}

>> D={-2000 -2000 2000 -1000 -2000 -2000 -500 -2000 4000 -2000 -500 2000 -2000}

e) Using MATLAB, extract the first column, the third row, second and fourth row, the 10th and
13 column of [K]

>> K(:,1)

>> K(3,:)

>> K([2,4],:)

>> K(:,[10,13])

f) Using MATLAB, delete the first row and 13th column of matrix [K]

>> K(1,:)=[ ]

>> K(1,:)=[ ]

Das könnte Ihnen auch gefallen