SlideShare a Scribd company logo
3
Most read
5
Most read
12
Most read
MATRIX MANIPULATION IN
MATLAB
Mohamed Loey
Matlab
Matlab
MATRIX
>> A = [1 2 3; 4 5 6 ;7 8 9]
A =
1 2 3
4 5 6
7 8 9
Matlab
Addition and Subtraction of Matrices
>> a = [ 1 2 3 ; 4 5 6; 7 8 9];
b = [ 7 5 6 ; 2 0 8; 5 7 1];
c = a + b
c =
8 7 9
6 5 14
12 15 10
Matlab
Scalar Operations of Matrices
>> a = [ 10 12 23 ; 14 8 6; 27 8 9];
b = 2;
c = a + b
c =
12 14 25
16 10 8
29 10 11
Matlab
Transpose of a Matrix
>> a = [ 10 12 23 ; 14 8 6; 27 8 9];
b = a’
b =
10 14 27
12 8 8
23 6 9
Matlab
Matrix Multiplication
>> a = [ 1 2 3; 2 3 4; 1 2 5];
b = [ 2 1 3 ; 5 0 -2; 2 3 -1];
prod = a * b
prod =
18 10 -4
27 14 -4
22 16 -6
Matlab
Inverse of a Matrix
>> a = [ 1 2 3; 2 3 4; 1 2 5];
inv(a)
ans =
-3.5000 2.0000 0.5000
3.0000 -1.0000 -1.0000
-0.5000 0 0.5000
Matlab
Colon Operator ‘:’
>>C3 = A(:,3)
C3 =
3
6
9
Matlab
Colon Operator ‘:’
>>R2 = A(2,:)
R2 =
4 5 6
Matlab
Colon Operator ‘:’
>>T2 = A(1:2,1:3)
T2 =
1 2 3
4 5 6
Matlab
GENERATING MATRICES
• zeros(M,N) generates an M x N matrix of zeros
• ones(M,N) generates an M x N matrix of ones
• rand(M,N) generates an M x N matrix whose
entries are uniformly-distributed random numbers
in the interval [0:0;1:0]
• randn(M,N) generates an M x N matrix whose
numbers are normally-distributed (i.e., Gaussian)
numbers with mean 0 and variance 1
Matlab
GENERATING MATRICES
>> K = 5*ones(3,3)
K =
5 5 5
5 5 5
5 5 5
Matlab
GENERATING MATRICES
>>B = rand(2,4)
B =
0.8147 0.1270 0.6324 0.2785
0.9058 0.9134 0.0975 0.5469
Matlab
MATRIX CONCATENATION
>> B=[1 2;3 4]
B =
1 2
3 4
Matlab
MATRIX CONCATENATION
>> C = [B B;B+4 B-1]
C =
1 2 1 2
3 4 3 4
5 6 0 1
7 8 2 3
Matlab
DELETING ROWS AND COLUMNS
>> C(:,2)=[]
C =
1 1 2
3 3 4
5 0 1
7 2 3
Matlab
OBTAINING INFORMATION ABOUT
MATRIX PROPERTIES
B = [5 1 2; 3 9 4; 7 6 8]
B =
5 1 2
3 9 4
7 6 8
Matlab
OBTAINING INFORMATION ABOUT
MATRIX PROPERTIES
>> max(B)
ans =
7 9 8
Matlab
OBTAINING INFORMATION ABOUT
MATRIX PROPERTIES
>> [V,R] = max(B)
V =
7 9 8
R =
3 2 3
Matlab
OBTAINING INFORMATION ABOUT
MATRIX PROPERTIES
The function size(A) returns a row
vector with components M and N
>> size(B)
ans = 3 3
Matlab
OBTAINING INFORMATION ABOUT
MATRIX PROPERTIES
The function ndims(A) returns the
number of dimension of the array.
>> ndims(B)
ans = 2
Matlab
Function whos
>> whos B
Name Size Bytes Class Attributes
B 3x3 72 double
Thanks For Listening
Mohamed Loey

More Related Content

PPTX
Deep neural networks
PPTX
Theory of Computation "Chapter 1, introduction"
PDF
Matlab for beginners, Introduction, signal processing
PPT
Introduction to matlab
PPTX
Turing machine-TOC
PPTX
Regular Expression Examples.pptx
PDF
Comparison between runtime polymorphism and compile time polymorphism
PPTX
Merge Sort
Deep neural networks
Theory of Computation "Chapter 1, introduction"
Matlab for beginners, Introduction, signal processing
Introduction to matlab
Turing machine-TOC
Regular Expression Examples.pptx
Comparison between runtime polymorphism and compile time polymorphism
Merge Sort

What's hot (20)

PPTX
Knapsack problem using greedy approach
PPTX
Recurrent Neural Networks (RNNs)
PPTX
8 queens problem using back tracking
ODP
OOP java
PDF
Matlab-Data types and operators
PPTX
Command line arguments
PPT
Chomsky Hierarchy.ppt
PPTX
Boyer moore algorithm
PPTX
closure properties of regular language.pptx
PDF
Matlab intro
PDF
Introduction to matlab
PPTX
Tsp branch and-bound
PPT
Master method theorem
PPT
Introduction to matlab
PPTX
Python-DataAbstarction.pptx
PPTX
Object Oriented Programming in Python
PPTX
Presentation on python
PPTX
Context free grammar
PPT
DESIGN AND ANALYSIS OF ALGORITHMS
PPT
Backtracking
Knapsack problem using greedy approach
Recurrent Neural Networks (RNNs)
8 queens problem using back tracking
OOP java
Matlab-Data types and operators
Command line arguments
Chomsky Hierarchy.ppt
Boyer moore algorithm
closure properties of regular language.pptx
Matlab intro
Introduction to matlab
Tsp branch and-bound
Master method theorem
Introduction to matlab
Python-DataAbstarction.pptx
Object Oriented Programming in Python
Presentation on python
Context free grammar
DESIGN AND ANALYSIS OF ALGORITHMS
Backtracking
Ad

Similar to Matrix Manipulation in Matlab (20)

PPT
Matlab introduction
PPT
Matlab introduction
PPTX
Introduction to matlab
PPT
Chapter 6 Matrices in MATLAB
PPT
Matlab on basic mathematics
PPT
Matlab an Introduction_Lecture_for all.ppt
PPS
PPT
Matlab practical and lab session
PDF
Matlab
DOCX
A practical work of matlab
PPT
Matlab introduction
PPTX
1. Introduction to Computing - MATLAB.pptx
PDF
Notes on MATLAB - Basic Cheatsheet
PPTX
Matlab-1.pptx
PPTX
An Introduction to MATLAB for beginners
PPT
Introduction to Matlab.ppt
PPTX
Basic MATLAB-Presentation.pptx
PPTX
Variables in matlab
PDF
Basics of Matlab for students and faculty
PPTX
Introduction to matlab lecture 2 of 4
Matlab introduction
Matlab introduction
Introduction to matlab
Chapter 6 Matrices in MATLAB
Matlab on basic mathematics
Matlab an Introduction_Lecture_for all.ppt
Matlab practical and lab session
Matlab
A practical work of matlab
Matlab introduction
1. Introduction to Computing - MATLAB.pptx
Notes on MATLAB - Basic Cheatsheet
Matlab-1.pptx
An Introduction to MATLAB for beginners
Introduction to Matlab.ppt
Basic MATLAB-Presentation.pptx
Variables in matlab
Basics of Matlab for students and faculty
Introduction to matlab lecture 2 of 4
Ad

More from Mohamed Loey (20)

PDF
Lecture 6: Deep Learning Applications
PDF
Lecture 5: Convolutional Neural Network Models
PDF
Lecture 4: Deep Learning Frameworks
PDF
Lecture 4: How it Works: Convolutional Neural Networks
PPTX
Lecture 3: Convolutional Neural Networks
PDF
Lecture 2: Artificial Neural Network
PDF
Lecture 1: Deep Learning for Computer Vision
PDF
Design of an Intelligent System for Improving Classification of Cancer Diseases
PDF
Computer Security - CCNA Security - Lecture 2
PDF
Computer Security - CCNA Security - Lecture 1
PDF
Algorithms Lecture 8: Pattern Algorithms
PDF
Algorithms Lecture 7: Graph Algorithms
PDF
Algorithms Lecture 6: Searching Algorithms
PDF
Algorithms Lecture 5: Sorting Algorithms II
PDF
Algorithms Lecture 4: Sorting Algorithms I
PDF
Algorithms Lecture 3: Analysis of Algorithms II
PDF
Algorithms Lecture 2: Analysis of Algorithms I
PDF
Algorithms Lecture 1: Introduction to Algorithms
PDF
Convolutional Neural Network Models - Deep Learning
PDF
Deep Learning - Overview of my work II
Lecture 6: Deep Learning Applications
Lecture 5: Convolutional Neural Network Models
Lecture 4: Deep Learning Frameworks
Lecture 4: How it Works: Convolutional Neural Networks
Lecture 3: Convolutional Neural Networks
Lecture 2: Artificial Neural Network
Lecture 1: Deep Learning for Computer Vision
Design of an Intelligent System for Improving Classification of Cancer Diseases
Computer Security - CCNA Security - Lecture 2
Computer Security - CCNA Security - Lecture 1
Algorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 7: Graph Algorithms
Algorithms Lecture 6: Searching Algorithms
Algorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 4: Sorting Algorithms I
Algorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 1: Introduction to Algorithms
Convolutional Neural Network Models - Deep Learning
Deep Learning - Overview of my work II

Recently uploaded (20)

PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Insiders guide to clinical Medicine.pdf
PDF
Pre independence Education in Inndia.pdf
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Cell Structure & Organelles in detailed.
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Cell Types and Its function , kingdom of life
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
master seminar digital applications in india
PDF
Sports Quiz easy sports quiz sports quiz
PDF
RMMM.pdf make it easy to upload and study
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
O7-L3 Supply Chain Operations - ICLT Program
Insiders guide to clinical Medicine.pdf
Pre independence Education in Inndia.pdf
Computing-Curriculum for Schools in Ghana
Cell Structure & Organelles in detailed.
102 student loan defaulters named and shamed – Is someone you know on the list?
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
GDM (1) (1).pptx small presentation for students
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Basic Mud Logging Guide for educational purpose
Cell Types and Its function , kingdom of life
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPH.pptx obstetrics and gynecology in nursing
master seminar digital applications in india
Sports Quiz easy sports quiz sports quiz
RMMM.pdf make it easy to upload and study

Matrix Manipulation in Matlab