SlideShare a Scribd company logo
MATLAB
Developed by
Pranoti R. Doke
Date:
1
Chapter 5
(Useful Matrices Generators )
Useful Matrices Generators :
2
Zeros a matrix filled with zeros
ones a matrix filled with ones
rand a matrix with uniformly distributed random elements
randn a matrix with normally distributed random elements
eye identity matrix
>> a = zeros(2,3)
a =0 0 0
0 0 0
>> b = ones(2,2)/2
b =
0.5000 0.5000
0.5000 0.5000
>> u = rand(1,5)
u =
0.9218 0.7382 0.1763 0.4057 0.9355
1/7 …
3
>> n = randn(5,5)
n =
-0.4326 1.1909 -0.1867 0.1139 0.2944
-1.6656 1.1892 0.7258 1.0668 -1.3362
0.1253 -0.0376 -0.5883 0.0593 0.7143
0.2877 0.3273 2.1832 -0.0956 1.6236
-1.1465 0.1746 -0.1364 -0.8323 -0.6918
>> eye(3)
ans
1 0 0
0 1 0
0 0 1
2/7 …
4
>> a = [1 2 3 ; 4 5 6 ; 7 8 9]
a =1 2 3
4 5 6
7 8 9
>> a(3 , 2)
ans = 8
>> a(2 , :)
ans = 4 5 6
>> a(:,3)
ans = 3
6
9
3/7 …
5
(ref.Basics of Matlab and Beyond)
>> a = [1 2 3 ; 4 5 6 ; 7 8 9]
a =
1 2 3
4 5 6
7 8 9
>> a(: , : , 2) = a*2
a(: , : , 1) =
1 2 3
4 5 6
7 8 9
a(: , : , 2) =
2 4 6
8 10 12
14 16 18
>> a (: , : ,3) = eye(3)
a(: , : , 3) =
1 0 0
0 1 0
0 0 1
Examples to solve :
6
Q). Create 3*3 ones matrix
Q). Create 4*4 zeros matrix
Q). Calculate rand and randn
Q). Show 4*4 identity matrix using MATLAB command

More Related Content

PPT
PDF
Linear Regression Implementation From Scratch
PPT
Introduction to MatLab programming
PPTX
Importance of matlab
PPSX
Matrix Manipulation in Matlab
PPT
Introduction to MATLAB
PPTX
MATLAB - Arrays and Matrices
PPTX
Matrices in matlab
Linear Regression Implementation From Scratch
Introduction to MatLab programming
Importance of matlab
Matrix Manipulation in Matlab
Introduction to MATLAB
MATLAB - Arrays and Matrices
Matrices in matlab

Similar to Chapter 5 Useful Matrices Generators (20)

PDF
PPTX
Matlab Tutorial
PDF
Matlab Intro to Arrays Guide for Beginners.pdf
PDF
Introduction to MATLAB
PDF
Introduction to MATLAB 1
PDF
computational brrtyuuufdddfgggxxzzcv.pdf
PPTX
Matlab ch1 (4)
PPTX
Introduction to Matlab and application.pptx
PDF
PPT
Matlab Tutorial.ppt
PDF
Matlab pt1
DOC
Matlabtut1
PPTX
mat lab introduction and basics to learn
PDF
Matlab intro notes
PDF
Notes on MATLAB - Basic Cheatsheet
PDF
Matlab cheatsheet
PPTX
Matlab-1.pptx
PPTX
Basic MATLAB-Presentation.pptx
PPT
MATLAB-Introd.ppt
PPTX
MATLAB ARRAYS
Matlab Tutorial
Matlab Intro to Arrays Guide for Beginners.pdf
Introduction to MATLAB
Introduction to MATLAB 1
computational brrtyuuufdddfgggxxzzcv.pdf
Matlab ch1 (4)
Introduction to Matlab and application.pptx
Matlab Tutorial.ppt
Matlab pt1
Matlabtut1
mat lab introduction and basics to learn
Matlab intro notes
Notes on MATLAB - Basic Cheatsheet
Matlab cheatsheet
Matlab-1.pptx
Basic MATLAB-Presentation.pptx
MATLAB-Introd.ppt
MATLAB ARRAYS
Ad

More from Pranoti Doke (19)

PDF
Unit 3 cnd physical layer_switching_pranoti doke_MSBTE
PDF
Unit 3 CND physical layer_switching_pranoti doke_MSBTE
PDF
Unit 3 CND_Physical Layer_Multiplexing_Pranoti Doke
PDF
Unit 3_CND Physical Layer_MODEMS_Pranoti Doke
PDF
Unit 3 _CND_22634_ physical layer_transmission medium_pranoti doke_MSBTE
PDF
Programmable Logic Controller by Pranoti R. Doke_MSBTE
PDF
C programming Ms. Pranoti Doke
PDF
C programming_MSBTE_Diploma_Pranoti Doke
PDF
Unit 2 cnd_22634_pranoti doke_MSBTE
PPTX
CND_22634_UNIT1_MSBTE_Computer network and Data Communication
PPT
Chapter 10 Programming in Matlab
PPT
Chapter 9 Display Commands in MATLAB
PPT
Chapter 8 Data Types in MATLAB
PPT
Chapter 7 Formats in MATLAB
PPT
Chapter 6 Matrices in MATLAB
PPT
Chapter 4 Keyboard in MATLAB Shortcuts
PPT
Chapter 3 Commands at MATLAB Command Window
PPT
Chapter 2 Basics of MATLAB
PPT
Chapter 1 matlab demo
Unit 3 cnd physical layer_switching_pranoti doke_MSBTE
Unit 3 CND physical layer_switching_pranoti doke_MSBTE
Unit 3 CND_Physical Layer_Multiplexing_Pranoti Doke
Unit 3_CND Physical Layer_MODEMS_Pranoti Doke
Unit 3 _CND_22634_ physical layer_transmission medium_pranoti doke_MSBTE
Programmable Logic Controller by Pranoti R. Doke_MSBTE
C programming Ms. Pranoti Doke
C programming_MSBTE_Diploma_Pranoti Doke
Unit 2 cnd_22634_pranoti doke_MSBTE
CND_22634_UNIT1_MSBTE_Computer network and Data Communication
Chapter 10 Programming in Matlab
Chapter 9 Display Commands in MATLAB
Chapter 8 Data Types in MATLAB
Chapter 7 Formats in MATLAB
Chapter 6 Matrices in MATLAB
Chapter 4 Keyboard in MATLAB Shortcuts
Chapter 3 Commands at MATLAB Command Window
Chapter 2 Basics of MATLAB
Chapter 1 matlab demo
Ad

Recently uploaded (20)

PDF
Modernizing IT for the age of AI - Jason Aloia, Freshworks
PDF
UNIT 1 -3 Factors Influencing RURAL CONSUMER BEHAVIOUR.pdf
PDF
AI & Automation: The Future of Marketing or the End of Creativity - Matthew W...
PPTX
Amazon - STRATEGIC.......................pptx
PDF
Mastering Content Strategy in 2025 ss.pdf
PDF
Prove and Prioritize Profitability in Every Marketing Campaign - Zach Sherrod...
PDF
How a Travel Company Can Implement Content Marketing
PPTX
Presentation - MindfulHeal Digital Ayurveda GTM & Marketing Plan.pptx
PPTX
"Best Healthcare Digital Marketing Ideas
PDF
Pay-Per-Click Marketing: Strategies That Actually Work in 2025
DOCX
Parkville marketing plan .......MR.docx
PPTX
Best Digital marketing service provider in Chandigarh.pptx
PDF
Hidden gems in Microsoft ads with Navah Hopkins
PPTX
The evolution of the internet - its impacts on consumers
PDF
exceptionalinsights.group visitor traffic statistics 08-08-25
PPTX
Sumit Saxena IIM J Project Market segmentation.pptx
PPTX
UNIT 3 - 5 INDUSTRIAL PRICING.ppt x
PPTX
Ipsos+Protocols+Playbook+V1.2+(DEC2024)+final+IntClientUseOnly.pptx
PDF
Future Retail Disruption Trends and Observations
PDF
Digital Marketing Agency in Thrissur with Proven Strategies for Local Growth
Modernizing IT for the age of AI - Jason Aloia, Freshworks
UNIT 1 -3 Factors Influencing RURAL CONSUMER BEHAVIOUR.pdf
AI & Automation: The Future of Marketing or the End of Creativity - Matthew W...
Amazon - STRATEGIC.......................pptx
Mastering Content Strategy in 2025 ss.pdf
Prove and Prioritize Profitability in Every Marketing Campaign - Zach Sherrod...
How a Travel Company Can Implement Content Marketing
Presentation - MindfulHeal Digital Ayurveda GTM & Marketing Plan.pptx
"Best Healthcare Digital Marketing Ideas
Pay-Per-Click Marketing: Strategies That Actually Work in 2025
Parkville marketing plan .......MR.docx
Best Digital marketing service provider in Chandigarh.pptx
Hidden gems in Microsoft ads with Navah Hopkins
The evolution of the internet - its impacts on consumers
exceptionalinsights.group visitor traffic statistics 08-08-25
Sumit Saxena IIM J Project Market segmentation.pptx
UNIT 3 - 5 INDUSTRIAL PRICING.ppt x
Ipsos+Protocols+Playbook+V1.2+(DEC2024)+final+IntClientUseOnly.pptx
Future Retail Disruption Trends and Observations
Digital Marketing Agency in Thrissur with Proven Strategies for Local Growth

Chapter 5 Useful Matrices Generators

  • 1. MATLAB Developed by Pranoti R. Doke Date: 1 Chapter 5 (Useful Matrices Generators )
  • 2. Useful Matrices Generators : 2 Zeros a matrix filled with zeros ones a matrix filled with ones rand a matrix with uniformly distributed random elements randn a matrix with normally distributed random elements eye identity matrix >> a = zeros(2,3) a =0 0 0 0 0 0 >> b = ones(2,2)/2 b = 0.5000 0.5000 0.5000 0.5000 >> u = rand(1,5) u = 0.9218 0.7382 0.1763 0.4057 0.9355
  • 3. 1/7 … 3 >> n = randn(5,5) n = -0.4326 1.1909 -0.1867 0.1139 0.2944 -1.6656 1.1892 0.7258 1.0668 -1.3362 0.1253 -0.0376 -0.5883 0.0593 0.7143 0.2877 0.3273 2.1832 -0.0956 1.6236 -1.1465 0.1746 -0.1364 -0.8323 -0.6918 >> eye(3) ans 1 0 0 0 1 0 0 0 1
  • 4. 2/7 … 4 >> a = [1 2 3 ; 4 5 6 ; 7 8 9] a =1 2 3 4 5 6 7 8 9 >> a(3 , 2) ans = 8 >> a(2 , :) ans = 4 5 6 >> a(:,3) ans = 3 6 9
  • 5. 3/7 … 5 (ref.Basics of Matlab and Beyond) >> a = [1 2 3 ; 4 5 6 ; 7 8 9] a = 1 2 3 4 5 6 7 8 9 >> a(: , : , 2) = a*2 a(: , : , 1) = 1 2 3 4 5 6 7 8 9 a(: , : , 2) = 2 4 6 8 10 12 14 16 18 >> a (: , : ,3) = eye(3) a(: , : , 3) = 1 0 0 0 1 0 0 0 1
  • 6. Examples to solve : 6 Q). Create 3*3 ones matrix Q). Create 4*4 zeros matrix Q). Calculate rand and randn Q). Show 4*4 identity matrix using MATLAB command