Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
31 views

Assignment 4

This document discusses solving problems using MATLAB by creating arrays and matrices, performing mathematical operations on them, and solving systems of linear equations. It provides examples of creating matrices using commands like zeros and eye, extracting portions of matrices to create new matrices, and solving sets of simultaneous linear equations.

Uploaded by

ILan Idzlan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Assignment 4

This document discusses solving problems using MATLAB by creating arrays and matrices, performing mathematical operations on them, and solving systems of linear equations. It provides examples of creating matrices using commands like zeros and eye, extracting portions of matrices to create new matrices, and solving sets of simultaneous linear equations.

Uploaded by

ILan Idzlan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ENG3202 Computer Programming

Creating and Mathematical Operation with Arrays-Matrices (Part 2)

Assignment 4

The following problems can be solved by writing commands in the Command


Window, or by writing a program in a script file and then executing the file.

1. Create the following matrix by typing one command. Do not type individual
element explicitly.

0 0 0 0 0
a) 𝐶 = 0 0 5 5 5
0 0 5 5 5
0 0 0 0 0
b) 𝐹 = 0 0 1 10 20
0 0 2 8 26
0 0 3 6 32

2. Create three row vector:

a = [7 2 -3 1 0], b = [-3 10 0 7 -2], c = [1 4 -6 5]

a) Use the three vectors in a MATLAB command to create a 3 X 3 matric such


that the first, second, and third rows consist of the first three elements of the
vectors a, b and c respectively.

b) Use the three vectors in a MATLAB command to create a 3 X 3 matrix


such that the first, second and third columns consist of the last three
elements of the vectors a, b and c respectively.

3. Create the following matrix A.

1 2 3 4 5 6
𝐴= 7 8 9 10 11 12
13 14 15 16 17 18

Use the matric A to:


a) Create a six-element row vector named ha that contains the elements of the first
row of A.
b) Create a three-element row vector named hb that contains the elements of the
sixth column of A.
c) Create a six-element row vector named hc that contains the first three elements
of the second row of A and the last three element of third row of A.

Page 1 of 2
4. The following matrix is defined in MATLAB:

3 3 3 0 0   0  0
𝑁= 0.7 0.8 0.9 1.0 1.1 1.2 1.3
14 12 10 8 6  4  2
22 17 12 7 2  −3 −8

a) Create a 2 X 2 matrix F from the first and third rows, and the second through
the sixth columns of matrix N.

b) Create a 2 X 7 matrix G from third and fourth rows and all the columns of
matrix N.

5. Using the zeros, ones and eye commands, create the following arrays:

1 1 0 0 1
1 0 0 1 1 0 0 0
a) b) 1 1
0 1 0 1 1 1 1 0 0 0
1 1 0 0 0

6. Create a 2 X 2 matric A in which all the elements are 1. Then reassign A to itself
(several time) such that A will become:

1 1 0 0 1 1 0 0
𝐴= 1 1 0 0 1 1 0 0
0 0 1 1 0 0 1 1
0 0 1 1 0 0 1 1

7. Solve the following system of three linear equations:

4𝑥 − 2.5𝑦 + 3𝑧 = 22.2
6𝑥 − 4𝑦 − 2𝑧 = 16.6
2𝑥 + 4𝑦 − 5.5𝑧 = −11.3

8. Solve the following system of three linear equations:

−𝑢 + 0.5𝑣 + 2𝑤 − 1.75𝑥 + 𝑦 = 9.5


3𝑢 + 12𝑣 − 9𝑤 + 1.5𝑥 − 6𝑦 = −4.5
3𝑢 − 1.5𝑣 + 𝑤 + 1.25𝑥 + 0.5𝑦 = −11.5
3𝑢 + 2𝑣 − 𝑤 + 1.5𝑥 − 3𝑦 = −3.5
6𝑢 + 3𝑣 + 2𝑤 + 𝑥 + 8𝑦 = −23.5

Page 2 of 2

You might also like