You are on page 1of 5

COMPUTER PROGRAMMING

SEAA 2413

QUIZ 1

Lecturer:
Ts D r N u r u l ‘A z i z a h M u k h l a s
Q1

3 3 3 3 3
K = −3 −1 1 3 5
9 4 −1 −6 −11

By referring to matrix K, write MATLAB statement to:

a) Create matrix K (use colon or linspace and other special matrices, do not
key-in the elements one-by-one), then,

b) Sum all the third-row elements of matrix K


c) Determine the largest element (use built-in function) in the third row
of matrix K
d) Calculate the mean value of elements (use built-in function) in the
second row of matrix K
e) Create a row vector of L by extracting the last three elements of the
second row and the first three elements of the third row of matrix K
f) Create a row vector Q from the summation of second and last row
of matrix K, based on each corresponding element
2
2
Q2

y =cos 0 : 0.02: log(100)

Write and use MATLAB program for the following array y to:

a) Determine total number of elements in the array


b) Get the 20th element
c) Get the third last element

3
3
Q3

The following table provide numerical information on qualitative


relationship between force, mass and acceleration. Given the formulation of
𝐹 = 𝑚𝑎

Use MATLAB coding, to:


a) Compute acceleration, 𝑎 required to complete the data
b) Find the highest Force, F recorded from the data and its corresponding
acceleration produce

Data 1 2 3 4 5
Force, F 10 20 20 10 30
Mass, m 2 2 4 2 2
Acceleration, 𝑎

4
4
Q4

A company must purchase five kinds of material. The following table gives
the price the company pays per ton for each material, along with the number
of tons purchased in the months of May, June and July.
Write MATLAB command to answer the below questions. You may create
your own variables.

a) Create a 5x3 matrix containing the amounts spent on each item for each
month
b) What is the total spent in each month?
c) What is the average of total spent on each material in the three-month
period?
d) What is the total spent on all materials in the three-month period?

5
5

You might also like