SlideShare a Scribd company logo
1 of 3
Download to read offline
http://www.tutorialspoint.com/matlab/matlab_matrics.htm Copyright © tutorialspoint.com
MATLAB - MATRIX
A matrix is a two-dimensionalarray of numbers.
InMATLAB, youcreate a matrix by entering elements ineachrow as comma or space delimited numbers and
using semicolons to mark the end of eachrow.
For example, let us create a 4-by-5 matrix a:
a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8]
MATLAB willexecute the above statement and returnthe following result:
a =
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
Referencing the Elements of a Matrix
To reference anelement inthe mth row and nth column, of a matrix mx, we write:
mx(m, n);
For example, to refer to the element inthe 2nd row and 5th column, of the matrix a, as created inthe last section,
we type:
a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8];
a(2,5)
MATLAB willexecute the above statement and returnthe following result:
ans =
6
To reference allthe elements inthe mth columnwe type A(:,m).
Let us create a columnvector v, fromthe elements of the 4th row of the matrix a:
a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8];
v = a(:,4)
MATLAB willexecute the above statement and returnthe following result:
v =
4
5
6
7
Youcanalso select the elements inthe mth throughnth columns, for this we write:
a(:,m:n)
Let us create a smaller matrix taking the elements fromthe second and third columns:
a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8];
a(:, 2:3)
MATLAB willexecute the above statement and returnthe following result:
ans =
2 3
3 4
4 5
5 6
Inthe same way, youcancreate a sub-matrix taking a sub-part of a matrix.
a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8];
a(:, 2:3)
MATLAB willexecute the above statement and returnthe following result:
ans =
2 3
3 4
4 5
5 6
Inthe same way, youcancreate a sub-matrix taking a sub-part of a matrix.
For example, let us create a sub-matrix sa taking the inner subpart of a:
3 4 5
4 5 6
To do this, write:
a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8];
sa = a(2:3,2:4)
MATLAB willexecute the above statement and returnthe following result:
sa =
3 4 5
4 5 6
Deleting a Row or a Column in a Matrix
Youcandelete anentire row or columnof a matrix by assigning anempty set of square braces [] to that row or
column. Basically, [] denotes anempty array.
For example, let us delete the fourthrow of a:
a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8];
a( 4 , : ) = []
MATLAB willexecute the above statement and returnthe following result:
a =
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
Next, let us delete the fifthcolumnof a:
a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8];
a(: , 5)=[]
MATLAB willexecute the above statement and returnthe following result:
a =
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7
Example
Inthis example, let us create a 3-by-3 matrix m, thenwe willcopy the second and third rows of this matrix twice to
create a 4-by-3 matrix.
Create a script file withthe following code:
a = [ 1 2 3 ; 4 5 6; 7 8 9];
new_mat = a([2,3,2,3],:)
Whenyourunthe file, it displays the following result:
new_mat =
4 5 6
7 8 9
4 5 6
7 8 9
Matrix Operations
Inthis section, let us discuss the following basic and commonly used matrix operations:
Additionand Subtractionof Matrices
Divisionof Matrices
Scalar Operations of Matrices
Transpose of a Matrix
Concatenating Matrices
Matrix Multiplication
Determinant of a Matrix
Inverse of a Matrix

More Related Content

What's hot

Matlab HTI summer training course_Lecture2
Matlab HTI summer training course_Lecture2Matlab HTI summer training course_Lecture2
Matlab HTI summer training course_Lecture2Mohamed Awni
 
Matlab HTI summer training course Lecture3
Matlab HTI summer training course Lecture3Matlab HTI summer training course Lecture3
Matlab HTI summer training course Lecture3Mohamed Awni
 
vlsi training in chandigarh
vlsi training in chandigarhvlsi training in chandigarh
vlsi training in chandigarhmatrixphagwara
 
data mining training in Bangalore
data mining training in Bangaloredata mining training in Bangalore
data mining training in Bangalorematrixphagwara
 
Summary of MATLAB Functions-Part1
Summary of MATLAB Functions-Part1Summary of MATLAB Functions-Part1
Summary of MATLAB Functions-Part1Elaf A.Saeed
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLABRavikiran A
 
Matlab matrices and arrays
Matlab matrices and arraysMatlab matrices and arrays
Matlab matrices and arraysAmeen San
 
Matlab presentation
Matlab presentationMatlab presentation
Matlab presentationUsama Zahid
 

What's hot (18)

Matlab HTI summer training course_Lecture2
Matlab HTI summer training course_Lecture2Matlab HTI summer training course_Lecture2
Matlab HTI summer training course_Lecture2
 
Matlab HTI summer training course Lecture3
Matlab HTI summer training course Lecture3Matlab HTI summer training course Lecture3
Matlab HTI summer training course Lecture3
 
Matlab tutorial 1
Matlab tutorial 1Matlab tutorial 1
Matlab tutorial 1
 
Matrices in matlab
Matrices in matlabMatrices in matlab
Matrices in matlab
 
vlsi training in chandigarh
vlsi training in chandigarhvlsi training in chandigarh
vlsi training in chandigarh
 
data mining training in Bangalore
data mining training in Bangaloredata mining training in Bangalore
data mining training in Bangalore
 
Matlab tut2
Matlab tut2Matlab tut2
Matlab tut2
 
Summary of MATLAB Functions-Part1
Summary of MATLAB Functions-Part1Summary of MATLAB Functions-Part1
Summary of MATLAB Functions-Part1
 
Matlab lecture 6 – newton raphson method@taj copy
Matlab lecture 6 – newton raphson method@taj   copyMatlab lecture 6 – newton raphson method@taj   copy
Matlab lecture 6 – newton raphson method@taj copy
 
Matlab
Matlab Matlab
Matlab
 
Matlab summary
Matlab summaryMatlab summary
Matlab summary
 
NACA Regula Falsi Method
 NACA Regula Falsi Method NACA Regula Falsi Method
NACA Regula Falsi Method
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
working with matrices in r
working with matrices in rworking with matrices in r
working with matrices in r
 
Merge sort
Merge sortMerge sort
Merge sort
 
Matlab matrices and arrays
Matlab matrices and arraysMatlab matrices and arrays
Matlab matrices and arrays
 
Matlab presentation
Matlab presentationMatlab presentation
Matlab presentation
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 

Viewers also liked

Tdc 2013 cum ne angajam
Tdc 2013   cum ne angajamTdc 2013   cum ne angajam
Tdc 2013 cum ne angajamAdrian Rusu
 
Meñoza(slide show) it1 hp2
Meñoza(slide show) it1 hp2Meñoza(slide show) it1 hp2
Meñoza(slide show) it1 hp2maitz
 
Hallgrímur pétursson
Hallgrímur péturssonHallgrímur pétursson
Hallgrímur péturssonsverrirs2859
 
IT1(HP2)_powerpoint presentation_Ocasiones
IT1(HP2)_powerpoint presentation_OcasionesIT1(HP2)_powerpoint presentation_Ocasiones
IT1(HP2)_powerpoint presentation_Ocasionesocasiones
 
Tdc 2013 career planning
Tdc 2013   career planningTdc 2013   career planning
Tdc 2013 career planningAdrian Rusu
 
Freys strategy in 5 years
Freys strategy in 5 yearsFreys strategy in 5 years
Freys strategy in 5 yearsYuan Yao
 

Viewers also liked (12)

Presentation2
Presentation2Presentation2
Presentation2
 
Tdc 2013 cum ne angajam
Tdc 2013   cum ne angajamTdc 2013   cum ne angajam
Tdc 2013 cum ne angajam
 
Meñoza(slide show) it1 hp2
Meñoza(slide show) it1 hp2Meñoza(slide show) it1 hp2
Meñoza(slide show) it1 hp2
 
Ss
SsSs
Ss
 
Hallgrímur pétursson
Hallgrímur péturssonHallgrímur pétursson
Hallgrímur pétursson
 
IT1(HP2)_powerpoint presentation_Ocasiones
IT1(HP2)_powerpoint presentation_OcasionesIT1(HP2)_powerpoint presentation_Ocasiones
IT1(HP2)_powerpoint presentation_Ocasiones
 
Matlab graphics
Matlab graphicsMatlab graphics
Matlab graphics
 
Tdc 2013 career planning
Tdc 2013   career planningTdc 2013   career planning
Tdc 2013 career planning
 
Presentation3
Presentation3Presentation3
Presentation3
 
Freys strategy in 5 years
Freys strategy in 5 yearsFreys strategy in 5 years
Freys strategy in 5 years
 
Katla 1
Katla 1Katla 1
Katla 1
 
Katla 1
Katla 1Katla 1
Katla 1
 

Similar to Matlab matrics

Matlab practical and lab session
Matlab practical and lab sessionMatlab practical and lab session
Matlab practical and lab sessionDr. Krishna Mohbey
 
Matlab Overviiew 2
Matlab Overviiew 2Matlab Overviiew 2
Matlab Overviiew 2Nazim Naeem
 
Importance of matlab
Importance of matlabImportance of matlab
Importance of matlabkrajeshk1980
 
Matlab ch1 intro
Matlab ch1 introMatlab ch1 intro
Matlab ch1 introRagu Nathan
 
Advanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsAdvanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsRay Phan
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxandreecapon
 
COMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptxCOMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptximman gwu
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to MatlabTariq kanher
 
Matlab intro notes
Matlab intro notesMatlab intro notes
Matlab intro notespawanss
 

Similar to Matlab matrics (20)

matlab Lesson 1
matlab Lesson 1matlab Lesson 1
matlab Lesson 1
 
Matlab practical and lab session
Matlab practical and lab sessionMatlab practical and lab session
Matlab practical and lab session
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Lecture 3.pptx
Lecture 3.pptxLecture 3.pptx
Lecture 3.pptx
 
Matlab booklet
Matlab bookletMatlab booklet
Matlab booklet
 
Matlab
MatlabMatlab
Matlab
 
Matlab Overviiew 2
Matlab Overviiew 2Matlab Overviiew 2
Matlab Overviiew 2
 
Matlab Tutorial
Matlab TutorialMatlab Tutorial
Matlab Tutorial
 
Importance of matlab
Importance of matlabImportance of matlab
Importance of matlab
 
Matlab ch1 intro
Matlab ch1 introMatlab ch1 intro
Matlab ch1 intro
 
Matlab guide
Matlab guideMatlab guide
Matlab guide
 
Advanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsAdvanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & Scientists
 
Ch1
Ch1Ch1
Ch1
 
Matlab
MatlabMatlab
Matlab
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
 
Basic concepts in_matlab
Basic concepts in_matlabBasic concepts in_matlab
Basic concepts in_matlab
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
 
COMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptxCOMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptx
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to Matlab
 
Matlab intro notes
Matlab intro notesMatlab intro notes
Matlab intro notes
 

More from pramodkumar1804 (20)

Matlab syntax
Matlab syntaxMatlab syntax
Matlab syntax
 
Matlab strings
Matlab stringsMatlab strings
Matlab strings
 
Matlab simulink
Matlab simulinkMatlab simulink
Matlab simulink
 
Matlab polynomials
Matlab polynomialsMatlab polynomials
Matlab polynomials
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
 
Matlab overview 3
Matlab overview 3Matlab overview 3
Matlab overview 3
 
Matlab overview 2
Matlab overview 2Matlab overview 2
Matlab overview 2
 
Matlab overview
Matlab overviewMatlab overview
Matlab overview
 
Matlab operators
Matlab operatorsMatlab operators
Matlab operators
 
Matlab numbers
Matlab numbersMatlab numbers
Matlab numbers
 
Matlab m files
Matlab m filesMatlab m files
Matlab m files
 
Matlab loops 2
Matlab loops 2Matlab loops 2
Matlab loops 2
 
Matlab loops
Matlab loopsMatlab loops
Matlab loops
 
Matlab integration
Matlab integrationMatlab integration
Matlab integration
 
Matlab gnu octave
Matlab gnu octaveMatlab gnu octave
Matlab gnu octave
 
Matlab operators
Matlab operatorsMatlab operators
Matlab operators
 
Matlab functions
Matlab functionsMatlab functions
Matlab functions
 
Matlab differential
Matlab differentialMatlab differential
Matlab differential
 
Matlab decisions
Matlab decisionsMatlab decisions
Matlab decisions
 
Matlab data import
Matlab data importMatlab data import
Matlab data import
 

Recently uploaded

Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 

Recently uploaded (20)

Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 

Matlab matrics

  • 1. http://www.tutorialspoint.com/matlab/matlab_matrics.htm Copyright © tutorialspoint.com MATLAB - MATRIX A matrix is a two-dimensionalarray of numbers. InMATLAB, youcreate a matrix by entering elements ineachrow as comma or space delimited numbers and using semicolons to mark the end of eachrow. For example, let us create a 4-by-5 matrix a: a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8] MATLAB willexecute the above statement and returnthe following result: a = 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 Referencing the Elements of a Matrix To reference anelement inthe mth row and nth column, of a matrix mx, we write: mx(m, n); For example, to refer to the element inthe 2nd row and 5th column, of the matrix a, as created inthe last section, we type: a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8]; a(2,5) MATLAB willexecute the above statement and returnthe following result: ans = 6 To reference allthe elements inthe mth columnwe type A(:,m). Let us create a columnvector v, fromthe elements of the 4th row of the matrix a: a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8]; v = a(:,4) MATLAB willexecute the above statement and returnthe following result: v = 4 5 6 7 Youcanalso select the elements inthe mth throughnth columns, for this we write: a(:,m:n) Let us create a smaller matrix taking the elements fromthe second and third columns: a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8];
  • 2. a(:, 2:3) MATLAB willexecute the above statement and returnthe following result: ans = 2 3 3 4 4 5 5 6 Inthe same way, youcancreate a sub-matrix taking a sub-part of a matrix. a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8]; a(:, 2:3) MATLAB willexecute the above statement and returnthe following result: ans = 2 3 3 4 4 5 5 6 Inthe same way, youcancreate a sub-matrix taking a sub-part of a matrix. For example, let us create a sub-matrix sa taking the inner subpart of a: 3 4 5 4 5 6 To do this, write: a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8]; sa = a(2:3,2:4) MATLAB willexecute the above statement and returnthe following result: sa = 3 4 5 4 5 6 Deleting a Row or a Column in a Matrix Youcandelete anentire row or columnof a matrix by assigning anempty set of square braces [] to that row or column. Basically, [] denotes anempty array. For example, let us delete the fourthrow of a: a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8]; a( 4 , : ) = [] MATLAB willexecute the above statement and returnthe following result: a = 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 Next, let us delete the fifthcolumnof a: a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8]; a(: , 5)=[]
  • 3. MATLAB willexecute the above statement and returnthe following result: a = 1 2 3 4 2 3 4 5 3 4 5 6 4 5 6 7 Example Inthis example, let us create a 3-by-3 matrix m, thenwe willcopy the second and third rows of this matrix twice to create a 4-by-3 matrix. Create a script file withthe following code: a = [ 1 2 3 ; 4 5 6; 7 8 9]; new_mat = a([2,3,2,3],:) Whenyourunthe file, it displays the following result: new_mat = 4 5 6 7 8 9 4 5 6 7 8 9 Matrix Operations Inthis section, let us discuss the following basic and commonly used matrix operations: Additionand Subtractionof Matrices Divisionof Matrices Scalar Operations of Matrices Transpose of a Matrix Concatenating Matrices Matrix Multiplication Determinant of a Matrix Inverse of a Matrix