SlideShare a Scribd company logo
1 of 6
Download to read offline
MATLAB NOTES
1
MATLAB NOTES
BY
AHMED Y. NASSAR
Surveying Department
Faculty of Engineering, Shoubra
Benha University
MATLAB NOTES
2
To create a matrix that has multiple rows, separate the rows with
semicolons.
>> a = [1 2 3; 4 5 6; 7 8 10]
a =
1 2 3
4 5 6
7 8 10
Another way to create a matrix is to use a function, such as ones, zeros,
or rand. For example, create a 5-by-1 column vector of zeros.
>> z = zeros(5,1)
z =
0
0
0
0
0
>> z = ones(5,2)
MATLAB NOTES
3
z =
1 1
1 1
1 1
1 1
1 1
>> z = rand(5,3)
z =
0.8147 0.0975 0.1576
0.9058 0.2785 0.9706
0.1270 0.5469 0.9572
0.9134 0.9575 0.4854
0.6324 0.9649 0.8003
To transpose a matrix, use a single quote ('):
>> a'
ans =
1 4 7
2 5 8
3 6 10
>> a + 10
MATLAB NOTES
4
ans =
11 12 13
14 15 16
17 18 20
To perform element-wise multiplication rather than matrix
multiplication, use the .* operator:
>> p = a.*a
p =
1 4 9
16 25 36
49 64 100
To perform Natural Matrix multiplication, use the * operator:
>> a * a
ans =
30 36 45
66 81 102
109 134 169
MATLAB NOTES
5
Concatenation
>> A = [a,a]
A =
1 2 3 1 2 3
4 5 6 4 5 6
7 8 10 7 8 10
>> A = [a; a]
A =
1 2 3
4 5 6
7 8 10
1 2 3
4 5 6
7 8 10
When you want to access selected elements of an array, use indexing.
>> a(2,2)
ans =
5
MATLAB NOTES
6
use a single subscript that traverses down each column in order:
>> a(6)
ans =
8
The colon operator also allows you to create an equally spaced vector
of values using the form start:step:end.
>> b = 0:20:200
b =
0 20 40 60 80 100 120 140 160 180 200
sqrt(X) is the square root of the elements of X. Complex results are
produced if X is not positive.
>> sqrt((-2:2)')
ans =
0.0000 + 1.4142i
0.0000 + 1.0000i
0.0000 + 0.0000i
1.0000 + 0.0000i
1.4142 + 0.0000i

More Related Content

Similar to Notes on MATLAB - Basic Cheatsheet

INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxDevaraj Chilakala
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabDnyanesh Patil
 
Chapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLABChapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLABPranoti Doke
 
Importance of matlab
Importance of matlabImportance of matlab
Importance of matlabkrajeshk1980
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersMurshida ck
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.pptkebeAman
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functionsjoellivz
 
Basics of Matlab for students and faculty
Basics of Matlab for students and facultyBasics of Matlab for students and faculty
Basics of Matlab for students and facultyAbhishekRanjan17318
 
INTRODUCTION TO MATLAB session with notes
  INTRODUCTION TO MATLAB   session with  notes  INTRODUCTION TO MATLAB   session with  notes
INTRODUCTION TO MATLAB session with notesInfinity Tech Solutions
 

Similar to Notes on MATLAB - Basic Cheatsheet (20)

Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptx
 
Mat lab
Mat labMat lab
Mat lab
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Chapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLABChapter 6 Matrices in MATLAB
Chapter 6 Matrices in MATLAB
 
Matlab
MatlabMatlab
Matlab
 
MATLAB - Arrays and Matrices
MATLAB - Arrays and MatricesMATLAB - Arrays and Matrices
MATLAB - Arrays and Matrices
 
MATLAB ARRAYS
MATLAB ARRAYSMATLAB ARRAYS
MATLAB ARRAYS
 
20100528
2010052820100528
20100528
 
20100528
2010052820100528
20100528
 
Importance of matlab
Importance of matlabImportance of matlab
Importance of matlab
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
 
Matlab quick quide3.4
Matlab  quick quide3.4Matlab  quick quide3.4
Matlab quick quide3.4
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginners
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.ppt
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functions
 
Basics of Matlab for students and faculty
Basics of Matlab for students and facultyBasics of Matlab for students and faculty
Basics of Matlab for students and faculty
 
INTRODUCTION TO MATLAB session with notes
  INTRODUCTION TO MATLAB   session with  notes  INTRODUCTION TO MATLAB   session with  notes
INTRODUCTION TO MATLAB session with notes
 
matlab Lesson 1
matlab Lesson 1matlab Lesson 1
matlab Lesson 1
 

More from Ahmed Nassar

Hydrographic Surveying : Safe Navigation
Hydrographic Surveying : Safe Navigation Hydrographic Surveying : Safe Navigation
Hydrographic Surveying : Safe Navigation Ahmed Nassar
 
DETERMINATION OF THE EARTH’S RADIUS, MASS, AND GRAVITIONAL CONSTANT - PHYSIC...
DETERMINATION OF THE EARTH’S RADIUS, MASS, AND GRAVITIONAL CONSTANT  - PHYSIC...DETERMINATION OF THE EARTH’S RADIUS, MASS, AND GRAVITIONAL CONSTANT  - PHYSIC...
DETERMINATION OF THE EARTH’S RADIUS, MASS, AND GRAVITIONAL CONSTANT - PHYSIC...Ahmed Nassar
 
Remote Sensing - Operating Satellites
Remote Sensing -  Operating SatellitesRemote Sensing -  Operating Satellites
Remote Sensing - Operating SatellitesAhmed Nassar
 
Photogrammetry - Stereoscopic Parallax
Photogrammetry - Stereoscopic ParallaxPhotogrammetry - Stereoscopic Parallax
Photogrammetry - Stereoscopic ParallaxAhmed Nassar
 
Hydrographic Surveying - Depth Sounding Equipment
Hydrographic Surveying - Depth Sounding EquipmentHydrographic Surveying - Depth Sounding Equipment
Hydrographic Surveying - Depth Sounding EquipmentAhmed Nassar
 
Hydrographic Surveying - Geodetic Control And Tidal Effects
Hydrographic Surveying - Geodetic Control And Tidal Effects Hydrographic Surveying - Geodetic Control And Tidal Effects
Hydrographic Surveying - Geodetic Control And Tidal Effects Ahmed Nassar
 
Hydrographic Surveying - Positioning
Hydrographic Surveying - PositioningHydrographic Surveying - Positioning
Hydrographic Surveying - PositioningAhmed Nassar
 
Hydrographic Surveying - Basic Measurements And Equipments
Hydrographic Surveying - Basic Measurements And EquipmentsHydrographic Surveying - Basic Measurements And Equipments
Hydrographic Surveying - Basic Measurements And EquipmentsAhmed Nassar
 
حقوق الانسان في مصر الفرعونية
حقوق الانسان في مصر الفرعونيةحقوق الانسان في مصر الفرعونية
حقوق الانسان في مصر الفرعونيةAhmed Nassar
 
The Importance of Railway in Transportation
The Importance of Railway in TransportationThe Importance of Railway in Transportation
The Importance of Railway in TransportationAhmed Nassar
 
Geometric Design of Roads and Highways
Geometric Design of Roads and HighwaysGeometric Design of Roads and Highways
Geometric Design of Roads and HighwaysAhmed Nassar
 
The Function of Electric Power Systems
The Function of Electric Power SystemsThe Function of Electric Power Systems
The Function of Electric Power SystemsAhmed Nassar
 
Photogrammetry: Stereoscopy and Parallax
Photogrammetry: Stereoscopy and ParallaxPhotogrammetry: Stereoscopy and Parallax
Photogrammetry: Stereoscopy and ParallaxAhmed Nassar
 
Geodesy - Definition, Types, Uses and Applications
Geodesy - Definition, Types, Uses and ApplicationsGeodesy - Definition, Types, Uses and Applications
Geodesy - Definition, Types, Uses and ApplicationsAhmed Nassar
 
Geology - rocks | جيولوجيا - الصخور
Geology - rocks | جيولوجيا - الصخورGeology - rocks | جيولوجيا - الصخور
Geology - rocks | جيولوجيا - الصخورAhmed Nassar
 
Geology - earthquakes | جيولوجيا - الزلازل
Geology - earthquakes | جيولوجيا - الزلازلGeology - earthquakes | جيولوجيا - الزلازل
Geology - earthquakes | جيولوجيا - الزلازلAhmed Nassar
 
Photogrammetry - Space Resection by Collinearity Equations
Photogrammetry - Space Resection by Collinearity EquationsPhotogrammetry - Space Resection by Collinearity Equations
Photogrammetry - Space Resection by Collinearity EquationsAhmed Nassar
 
Geodetic Astronomy - MOTION IN THE HEAVENS - EARTH, SUN AND STARS
Geodetic Astronomy - MOTION IN THE HEAVENS - EARTH, SUN AND STARSGeodetic Astronomy - MOTION IN THE HEAVENS - EARTH, SUN AND STARS
Geodetic Astronomy - MOTION IN THE HEAVENS - EARTH, SUN AND STARSAhmed Nassar
 
PHOTOGRAMMETRY: GROUND CONTROL FOR AERIAL PHOTOGRAMMETRY نقاط الضبط الأرضي في...
PHOTOGRAMMETRY: GROUND CONTROL FOR AERIAL PHOTOGRAMMETRY نقاط الضبط الأرضي في...PHOTOGRAMMETRY: GROUND CONTROL FOR AERIAL PHOTOGRAMMETRY نقاط الضبط الأرضي في...
PHOTOGRAMMETRY: GROUND CONTROL FOR AERIAL PHOTOGRAMMETRY نقاط الضبط الأرضي في...Ahmed Nassar
 

More from Ahmed Nassar (20)

Hydrographic Surveying : Safe Navigation
Hydrographic Surveying : Safe Navigation Hydrographic Surveying : Safe Navigation
Hydrographic Surveying : Safe Navigation
 
DETERMINATION OF THE EARTH’S RADIUS, MASS, AND GRAVITIONAL CONSTANT - PHYSIC...
DETERMINATION OF THE EARTH’S RADIUS, MASS, AND GRAVITIONAL CONSTANT  - PHYSIC...DETERMINATION OF THE EARTH’S RADIUS, MASS, AND GRAVITIONAL CONSTANT  - PHYSIC...
DETERMINATION OF THE EARTH’S RADIUS, MASS, AND GRAVITIONAL CONSTANT - PHYSIC...
 
Remote Sensing - Operating Satellites
Remote Sensing -  Operating SatellitesRemote Sensing -  Operating Satellites
Remote Sensing - Operating Satellites
 
Photogrammetry - Stereoscopic Parallax
Photogrammetry - Stereoscopic ParallaxPhotogrammetry - Stereoscopic Parallax
Photogrammetry - Stereoscopic Parallax
 
Hydrographic Surveying - Depth Sounding Equipment
Hydrographic Surveying - Depth Sounding EquipmentHydrographic Surveying - Depth Sounding Equipment
Hydrographic Surveying - Depth Sounding Equipment
 
Hydrographic Surveying - Geodetic Control And Tidal Effects
Hydrographic Surveying - Geodetic Control And Tidal Effects Hydrographic Surveying - Geodetic Control And Tidal Effects
Hydrographic Surveying - Geodetic Control And Tidal Effects
 
Hydrographic Surveying - Positioning
Hydrographic Surveying - PositioningHydrographic Surveying - Positioning
Hydrographic Surveying - Positioning
 
Hydrographic Surveying - Basic Measurements And Equipments
Hydrographic Surveying - Basic Measurements And EquipmentsHydrographic Surveying - Basic Measurements And Equipments
Hydrographic Surveying - Basic Measurements And Equipments
 
حقوق الانسان في مصر الفرعونية
حقوق الانسان في مصر الفرعونيةحقوق الانسان في مصر الفرعونية
حقوق الانسان في مصر الفرعونية
 
The Importance of Railway in Transportation
The Importance of Railway in TransportationThe Importance of Railway in Transportation
The Importance of Railway in Transportation
 
Geometric Design of Roads and Highways
Geometric Design of Roads and HighwaysGeometric Design of Roads and Highways
Geometric Design of Roads and Highways
 
The Function of Electric Power Systems
The Function of Electric Power SystemsThe Function of Electric Power Systems
The Function of Electric Power Systems
 
Types of Gears
Types of GearsTypes of Gears
Types of Gears
 
Photogrammetry: Stereoscopy and Parallax
Photogrammetry: Stereoscopy and ParallaxPhotogrammetry: Stereoscopy and Parallax
Photogrammetry: Stereoscopy and Parallax
 
Geodesy - Definition, Types, Uses and Applications
Geodesy - Definition, Types, Uses and ApplicationsGeodesy - Definition, Types, Uses and Applications
Geodesy - Definition, Types, Uses and Applications
 
Geology - rocks | جيولوجيا - الصخور
Geology - rocks | جيولوجيا - الصخورGeology - rocks | جيولوجيا - الصخور
Geology - rocks | جيولوجيا - الصخور
 
Geology - earthquakes | جيولوجيا - الزلازل
Geology - earthquakes | جيولوجيا - الزلازلGeology - earthquakes | جيولوجيا - الزلازل
Geology - earthquakes | جيولوجيا - الزلازل
 
Photogrammetry - Space Resection by Collinearity Equations
Photogrammetry - Space Resection by Collinearity EquationsPhotogrammetry - Space Resection by Collinearity Equations
Photogrammetry - Space Resection by Collinearity Equations
 
Geodetic Astronomy - MOTION IN THE HEAVENS - EARTH, SUN AND STARS
Geodetic Astronomy - MOTION IN THE HEAVENS - EARTH, SUN AND STARSGeodetic Astronomy - MOTION IN THE HEAVENS - EARTH, SUN AND STARS
Geodetic Astronomy - MOTION IN THE HEAVENS - EARTH, SUN AND STARS
 
PHOTOGRAMMETRY: GROUND CONTROL FOR AERIAL PHOTOGRAMMETRY نقاط الضبط الأرضي في...
PHOTOGRAMMETRY: GROUND CONTROL FOR AERIAL PHOTOGRAMMETRY نقاط الضبط الأرضي في...PHOTOGRAMMETRY: GROUND CONTROL FOR AERIAL PHOTOGRAMMETRY نقاط الضبط الأرضي في...
PHOTOGRAMMETRY: GROUND CONTROL FOR AERIAL PHOTOGRAMMETRY نقاط الضبط الأرضي في...
 

Recently uploaded

Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixingviprabot1
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 

Recently uploaded (20)

Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixing
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 

Notes on MATLAB - Basic Cheatsheet

  • 1. MATLAB NOTES 1 MATLAB NOTES BY AHMED Y. NASSAR Surveying Department Faculty of Engineering, Shoubra Benha University
  • 2. MATLAB NOTES 2 To create a matrix that has multiple rows, separate the rows with semicolons. >> a = [1 2 3; 4 5 6; 7 8 10] a = 1 2 3 4 5 6 7 8 10 Another way to create a matrix is to use a function, such as ones, zeros, or rand. For example, create a 5-by-1 column vector of zeros. >> z = zeros(5,1) z = 0 0 0 0 0 >> z = ones(5,2)
  • 3. MATLAB NOTES 3 z = 1 1 1 1 1 1 1 1 1 1 >> z = rand(5,3) z = 0.8147 0.0975 0.1576 0.9058 0.2785 0.9706 0.1270 0.5469 0.9572 0.9134 0.9575 0.4854 0.6324 0.9649 0.8003 To transpose a matrix, use a single quote ('): >> a' ans = 1 4 7 2 5 8 3 6 10 >> a + 10
  • 4. MATLAB NOTES 4 ans = 11 12 13 14 15 16 17 18 20 To perform element-wise multiplication rather than matrix multiplication, use the .* operator: >> p = a.*a p = 1 4 9 16 25 36 49 64 100 To perform Natural Matrix multiplication, use the * operator: >> a * a ans = 30 36 45 66 81 102 109 134 169
  • 5. MATLAB NOTES 5 Concatenation >> A = [a,a] A = 1 2 3 1 2 3 4 5 6 4 5 6 7 8 10 7 8 10 >> A = [a; a] A = 1 2 3 4 5 6 7 8 10 1 2 3 4 5 6 7 8 10 When you want to access selected elements of an array, use indexing. >> a(2,2) ans = 5
  • 6. MATLAB NOTES 6 use a single subscript that traverses down each column in order: >> a(6) ans = 8 The colon operator also allows you to create an equally spaced vector of values using the form start:step:end. >> b = 0:20:200 b = 0 20 40 60 80 100 120 140 160 180 200 sqrt(X) is the square root of the elements of X. Complex results are produced if X is not positive. >> sqrt((-2:2)') ans = 0.0000 + 1.4142i 0.0000 + 1.0000i 0.0000 + 0.0000i 1.0000 + 0.0000i 1.4142 + 0.0000i