0% found this document useful (0 votes)
210 views4 pages

Lab-1: Study On Basic Matrix Operations Using Matlab

This document describes a numerical techniques laboratory experiment conducted in Matlab. It involves representing matrices, performing basic matrix operations, and generating typical matrices. The student is instructed to observe the results of applying operations like addition, multiplication, and transposition to sample matrices. Commands to generate random, identity, zero and other matrices are also provided. Exercises involve implementing matrices, finding elements and inverses, and generating random matrices to compare results between runs.

Uploaded by

RaFaT HaQ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
210 views4 pages

Lab-1: Study On Basic Matrix Operations Using Matlab

This document describes a numerical techniques laboratory experiment conducted in Matlab. It involves representing matrices, performing basic matrix operations, and generating typical matrices. The student is instructed to observe the results of applying operations like addition, multiplication, and transposition to sample matrices. Commands to generate random, identity, zero and other matrices are also provided. Exercises involve implementing matrices, finding elements and inverses, and generating random matrices to compare results between runs.

Uploaded by

RaFaT HaQ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

University of Dhaka

Department of Electrical and Electronic Engineering


EEE-3102: Numerical Technique Laboratory

University of Dhaka
Department of Electrical and Electronic Engineering
EEE-3102: Numerical Technique Laboratory

Group :A
Class Roll : FH-073-018
Name : Md. Rafatul Haq
Date : 24/01/2022

Lab-1: Study on basic matrix operations using Matlab.

Instruction: Use the concept on matrix operations in Matlab tutorial for this Lab.
Representation of Matrix in Matlab:
Consider two matrices M and N given below

1 2 −2   3 −1 2 
M  3 −1 5 =
= N  5 1 −2 
   
 2 3 1   −1 4 1 
In Matlab, we can represent matrix A in an m-file using the following command
M=[1 2 -2;3 -1 5;2 3 1];
Similarly, we can represent matrix B as given below
N=[3 -1 2;5 1 -2;-1 4 1]

Table-1: Matrix Operations on M and/or N

Operation Description How to apply


+ Addition M+N
- Subtraction M-N
* Matrix multiplication M*N
.* Element-by-Element multiplication M.*N
/ Matrix division M/N
./ Element-by-Element division M./N
det Determination of a matrix Det(M)
inv Inverse of a matrix inv(M)
‘ Transpose of a matrix M’
diag Gives the diagonal of a matrix diag(M)
rank Gives the rank of a matrix Rank(M)

AKA/EEE-3102/Lab-1/20 January 2020 Page 1


University of Dhaka
Department of Electrical and Electronic Engineering
EEE-3102: Numerical Technique Laboratory

Observation-1: Apply all the above operations listed in Table-1 for matrices M and N. For the
operation on a single matrix, use matrix M. Just observe the results. You don’t need to show the
results in your lab report.

Observation-2: For the matrix M, find


(a) the first, middle and last elements of the 3rd column.
(b) the first, middle and last elements of the 2nd row.
(c) the whole of 3rd column and
(d) the whole of 2nd row
Just observe the results. You don’t need to show the results in your lab report.

Table-2: Additional command to generate typical matrices


Command Description
A = randn(n) A is an n×n random matrix having elements with random number.
A = ones(n) A is an n×n one-matrix having all elements equal to 1.
A = zeros(n) A is an n×n zero-matrix having all elements equal to 0.
A= eye(n) A is an n×n diagonal matrix whose diagonal elements are 1, all other elements are 0.
A = magic(n) A is an n×n magic matrix whose sum from any angle is the same.

Observation-3: Implement all of the typical matrices of size 5×5. Just observe the results. You don’t
need to show the results in your lab report.

AKA/EEE-3102/Lab-1/20 January 2020 Page 2


University of Dhaka
Department of Electrical and Electronic Engineering
EEE-3102: Numerical Technique Laboratory

Exercise
E1: Implement the following two matrices A and B in Matlab

 2 3 5 −1  3 1 2 −1
 −5 2 −1 2   −4 −5 5 2 
A=  B= 
 1 −4 7 6   1 −2 −3 3 
   
 5 2 1 −4   6 3 1 −4 
(a) Find the 3rd row named r3 of M1 where M1 is obtained by adding A and B. Put r3 below.
r3 = [2 -6 4 9]
(b) Find the 4th column named c5 of M2 where M2 is obtained by element-by-element
multiplication between A and B. Put c5 below.
1
c5 = 4
18
16
(c) Find the 4th element in the 2nd column named e42 of M3 where M3 is obtained by matrix
multiplication between A and B. Put e42 below.
e42 = -2
(d) Determine the inverse of matrix A and put it below
-0.5208 0.5417 0.3229 0.8854
-0.3542 0.7083 0.2396 0.8021
0.4792 -0.4583 -0.1771 -0.6146
-0.7083 0.9167 0.4792 1.1042
(e) Determine the transpose of matrix B and put it below
3 -4 1 6
1 -5 -2 3
2 5 -3 1
-1 2 3 -4

AKA/EEE-3102/Lab-1/20 January 2020 Page 3


University of Dhaka
Department of Electrical and Electronic Engineering
EEE-3102: Numerical Technique Laboratory

(f) Determine the rank of the matrix A and put it below


4
(g) Find the diagonal of matrix B and put it below

3
-5
-3
-4

E2: Generate a 5×5 one-matrix named N1, a magic matrix N2, and a diagonal matrix N3. Find a matrix
E after dividing N1 by N2, Use element-by element division for this purpose. Now, find a matrix F
after performing matrix multiplication between N2 and N3. Now find a matrix G by adding matrices E
and F. You don’t need to put these results in your report. Now find
(a) the determinant d of matrix G and put the result below
d = 4.7375e+06
(b) Find the 2nd element in the 4th row r24 of G and put the result below
r24 = 12.0833

E3: (a) write matlab code to generate a 3×3 random matrix and RUN it. RUN the code again. Are the
results obtained from these two run same? Justify your answer
The results obtained from these two runs were not the same.
1st RUN:
-0.3034 0.8884 -0.8095
0.2939 -1.1471 -2.9443
-0.7873 -1.0689 1.4384

2nd RUN:
0.3252 -1.7115 0.3192
-0.7549 -0.1022 0.3129
1.3703 -0.2414 -0.8649

AKA/EEE-3102/Lab-1/20 January 2020 Page 4

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy