SlideShare ist ein Scribd-Unternehmen logo
1 von 1
Downloaden Sie, um offline zu lesen
A Matlab Cheat-sheet (MIT 18.06, Fall 2007)
Basics:
save 'file.mat'         save variables to file.mat
load 'file.mat'         load variables from file.mat                              Constructing a few simple matrices:
diary on     record input/output to file diary                                    rand(12,4)   a 12×4 matrix with uniform random numbers in [0,1)
diary off    stop recording                                                       randn(12,4) a 12×4 matrix with Gaussian random (center 0, variance 1)
whos         list all variables currenly defined                                  zeros(12,4) a 12×4 matrix of zeros
clear        delete/undefine all variables                                        ones(12,4)   a 12×4 matrix of ones
help command            quick help on a given command                             eye(5)       a 5×5 identity matrix I (“eye”)
doc command             extensive help on a given command                         eye(12,4)    a 12×4 matrix whose first 4 rows are the 4×4 identity
                                                                                  linspace(1.2,4.7,100)
                                                                                                    row vector of 100 equally-spaced numbers from 1.2 to 4.7
Defining/changing variables:                                                      7:15   row vector of 7,8,9,…,14,15
x   =   3        define variable x to be 3                                        diag(x)        matrix whose diagonal is the entries of x (and other elements = 0)
x   =   [1 2 3] set x to the 1×3 row-vector (1,2,3)
x   =   [1 2 3]; same, but don't echo x to output                                 Portions of matrices and vectors:
x   =   [1;2;3] set x to the 3×1 column-vector (1,2,3)
A   =   [1 2 3 4;5 6 7 8;9 10 11 12];
                                                                                  x(2:12)           the 2nd to the 12th elements of x
       set A to the 3×4 matrix with rows 1,2,3,4 etc.                             x(2:end)          the 2nd to the last elements of x
x(2) = 7         change x from (1,2,3) to (1,7,3)                                 x(1:3:end)        every third element of x, from 1st to the last
A(2,1) = 0       change A2,1 from 5 to 0                                          x(:)              all the elements of x
                                                                                  A(5,:)            the row vector of every element in the 5th row of A
                                                                                  A(5,1:3)          the row vector of the first 3 elements in the 5th row of A
Arithmetic and functions of numbers:                                              A(:,2)            the column vector of every element in the 2nd column of A
3*4, 7+4, 2-6 8/3     multiply, add, subtract, and divide numbers                 diag(A)           column vector of the diagonal elements of A
3^7, 3^(8+2i)         compute 3 to the 7th power, or 3 to the 8+2i power
sqrt(-5)      compute the square root of –5
exp(12)       compute e12                                                         Solving linear equations:
log(3), log10(100) compute the natural log (ln) and base-10 log (log10)           A  b        for A a matrix and b a column vector, the solution x to Ax=b
abs(-5)       compute the absolute value |–5|                                     inv(A)       the inverse matrix A–1
                                                                                  [L,U,P] = lu(A)                the LU factorization PA=LU
sin(5*pi/3) compute the sine of 5π/3
                                                                                  eig(A)       the eigenvalues of A
besselj(2,6) compute the Bessel function J2(6)
                                                                                  [V,D] = eig(A) the columns of V are the eigenvectors of A, and
Arithmetic and functions of vectors and matrices:                                                  the diagonals diag(D) are the eigenvalues of A
x * 3 multiply every element of x by 3
x + 2 add 2 to every element of x                                                 Plotting:
x + y element-wise addition of two vectors x and y                                plot(y)       plot y as the y axis, with 1,2,3,… as the x axis
A * y product of a matrix A and a vector y                                        plot(x,y)     plot y versus x (must have same length)
A * B product of two matrices A and B                                             plot(x,A)     plot columns of A versus x (must have same # rows)
x * y not allowed if x and y are two column vectors!                              loglog(x,y) plot y versus x on a log-log scale
x .* y element-wise product of vectors x and y                                    semilogx(x,y)           plot y versus x with x on a log scale
A^3    the square matrix A to the 3rd power                                       semilogy(x,y)           plot y versus x with y on a log scale
x^3    not allowed if x is not a square matrix!                                   fplot(@(x) …expression…,[a,b])
x.^3   every element of x is taken to the 3rd power                                                          plot some expression in x from x=a to x=b
cos(x) the cosine of every element of x                                           axis equal      force the x and y axes of the current plot to be scaled equally
abs(A) the absolute value of every element of A                                   title('A Title')          add a title A Title at the top of the plot
exp(A) e to the power of every element of A                                       xlabel('blah')            label the x axis as blah
sqrt(A)          the square root of every element of A                            ylabel('blah')            label the y axis as blah
expm(A)          the matrix exponential eA                                        legend('foo','bar')                 label 2 curves in the plot foo and bar
sqrtm(A)         the matrix whose square is A                                     grid   include a grid in the plot
                                                                                  figure          open up a new figure window

              Transposes and dot products:
              x.', A.'        the transposes of x and A
              x', A'          the complex-conjugate of the transposes of x and A      dot(x,y), sum(x.*y) …two other ways to write the dot product
              x' * y          the dot (inner) product of two column vectors x and y   x * y'       the outer product of two column vectors x and y

Weitere ähnliche Inhalte

Was ist angesagt?

Ethical Dimensions of Artificial Intelligence (AI) by Rinshad Choorappara
Ethical Dimensions of Artificial Intelligence (AI) by Rinshad ChoorapparaEthical Dimensions of Artificial Intelligence (AI) by Rinshad Choorappara
Ethical Dimensions of Artificial Intelligence (AI) by Rinshad ChoorapparaRinshad Choorappara
 
Legal, Ethical, and Professional Issues In Information Security
Legal, Ethical, and Professional Issues In Information SecurityLegal, Ethical, and Professional Issues In Information Security
Legal, Ethical, and Professional Issues In Information SecurityCarl Ceder
 
Comparative of risk analysis methodologies
Comparative of risk analysis methodologiesComparative of risk analysis methodologies
Comparative of risk analysis methodologiesRamiro Cid
 
Anti-Forensics: Real world identification, analysis and prevention
Anti-Forensics: Real world identification, analysis and preventionAnti-Forensics: Real world identification, analysis and prevention
Anti-Forensics: Real world identification, analysis and preventionSeccuris Inc.
 
NIST 800-30 Intro to Conducting Risk Assessments - Part 1
NIST 800-30 Intro to Conducting Risk Assessments - Part 1NIST 800-30 Intro to Conducting Risk Assessments - Part 1
NIST 800-30 Intro to Conducting Risk Assessments - Part 1Denise Tawwab
 
Introduction to ESP32 Programming [Road to RIoT 2017]
Introduction to ESP32 Programming [Road to RIoT 2017]Introduction to ESP32 Programming [Road to RIoT 2017]
Introduction to ESP32 Programming [Road to RIoT 2017]Alwin Arrasyid
 
Fundamentals of Information Systems Security Chapter 9
Fundamentals of Information Systems Security Chapter 9Fundamentals of Information Systems Security Chapter 9
Fundamentals of Information Systems Security Chapter 9Dr. Ahmed Al Zaidy
 
A brief Intro to Digital Forensics
A brief Intro to Digital ForensicsA brief Intro to Digital Forensics
A brief Intro to Digital ForensicsManik Bhola
 
Smart Wireless Surveillance Monitoring using RASPBERRY PI
Smart Wireless Surveillance Monitoring using RASPBERRY PISmart Wireless Surveillance Monitoring using RASPBERRY PI
Smart Wireless Surveillance Monitoring using RASPBERRY PIKrishna Kumar
 
Information Security Awareness, Petronas Marketing Sudan
Information Security Awareness, Petronas Marketing SudanInformation Security Awareness, Petronas Marketing Sudan
Information Security Awareness, Petronas Marketing SudanAhmed Musaad
 
The Role of Legal Requirements in EMS
The Role of Legal Requirements in EMSThe Role of Legal Requirements in EMS
The Role of Legal Requirements in EMSPECB
 
ISO 27001 2013 A12 Operations Security Part 2 - by Software development compa...
ISO 27001 2013 A12 Operations Security Part 2 - by Software development compa...ISO 27001 2013 A12 Operations Security Part 2 - by Software development compa...
ISO 27001 2013 A12 Operations Security Part 2 - by Software development compa...iFour Consultancy
 
Shaping Your Future in Banking Cybersecurity
Shaping Your Future in Banking Cybersecurity Shaping Your Future in Banking Cybersecurity
Shaping Your Future in Banking Cybersecurity Dawn Yankeelov
 

Was ist angesagt? (20)

LTspice超入門
LTspice超入門LTspice超入門
LTspice超入門
 
Ethical Dimensions of Artificial Intelligence (AI) by Rinshad Choorappara
Ethical Dimensions of Artificial Intelligence (AI) by Rinshad ChoorapparaEthical Dimensions of Artificial Intelligence (AI) by Rinshad Choorappara
Ethical Dimensions of Artificial Intelligence (AI) by Rinshad Choorappara
 
Module 02 ftk imager
Module 02 ftk imagerModule 02 ftk imager
Module 02 ftk imager
 
Legal, Ethical, and Professional Issues In Information Security
Legal, Ethical, and Professional Issues In Information SecurityLegal, Ethical, and Professional Issues In Information Security
Legal, Ethical, and Professional Issues In Information Security
 
Comparative of risk analysis methodologies
Comparative of risk analysis methodologiesComparative of risk analysis methodologies
Comparative of risk analysis methodologies
 
ISO 27001 - Information Security Management System
ISO 27001 - Information Security Management SystemISO 27001 - Information Security Management System
ISO 27001 - Information Security Management System
 
Anti-Forensics: Real world identification, analysis and prevention
Anti-Forensics: Real world identification, analysis and preventionAnti-Forensics: Real world identification, analysis and prevention
Anti-Forensics: Real world identification, analysis and prevention
 
NIST 800-30 Intro to Conducting Risk Assessments - Part 1
NIST 800-30 Intro to Conducting Risk Assessments - Part 1NIST 800-30 Intro to Conducting Risk Assessments - Part 1
NIST 800-30 Intro to Conducting Risk Assessments - Part 1
 
Introduction to ESP32 Programming [Road to RIoT 2017]
Introduction to ESP32 Programming [Road to RIoT 2017]Introduction to ESP32 Programming [Road to RIoT 2017]
Introduction to ESP32 Programming [Road to RIoT 2017]
 
Physical Security Management System
Physical Security Management SystemPhysical Security Management System
Physical Security Management System
 
Fundamentals of Information Systems Security Chapter 9
Fundamentals of Information Systems Security Chapter 9Fundamentals of Information Systems Security Chapter 9
Fundamentals of Information Systems Security Chapter 9
 
A brief Intro to Digital Forensics
A brief Intro to Digital ForensicsA brief Intro to Digital Forensics
A brief Intro to Digital Forensics
 
Smart Wireless Surveillance Monitoring using RASPBERRY PI
Smart Wireless Surveillance Monitoring using RASPBERRY PISmart Wireless Surveillance Monitoring using RASPBERRY PI
Smart Wireless Surveillance Monitoring using RASPBERRY PI
 
PCI DSS
PCI DSSPCI DSS
PCI DSS
 
Information Security Awareness, Petronas Marketing Sudan
Information Security Awareness, Petronas Marketing SudanInformation Security Awareness, Petronas Marketing Sudan
Information Security Awareness, Petronas Marketing Sudan
 
nullcon 2011 - Penetration Testing a Biometric System
nullcon 2011 - Penetration Testing a Biometric Systemnullcon 2011 - Penetration Testing a Biometric System
nullcon 2011 - Penetration Testing a Biometric System
 
The Role of Legal Requirements in EMS
The Role of Legal Requirements in EMSThe Role of Legal Requirements in EMS
The Role of Legal Requirements in EMS
 
ISO 27001 2013 A12 Operations Security Part 2 - by Software development compa...
ISO 27001 2013 A12 Operations Security Part 2 - by Software development compa...ISO 27001 2013 A12 Operations Security Part 2 - by Software development compa...
ISO 27001 2013 A12 Operations Security Part 2 - by Software development compa...
 
Shaping Your Future in Banking Cybersecurity
Shaping Your Future in Banking Cybersecurity Shaping Your Future in Banking Cybersecurity
Shaping Your Future in Banking Cybersecurity
 
Iso 27001 awareness
Iso 27001 awarenessIso 27001 awareness
Iso 27001 awareness
 

Ähnlich wie Matlab cheatsheet

Ähnlich wie Matlab cheatsheet (20)

Matlab cheatsheet
Matlab cheatsheetMatlab cheatsheet
Matlab cheatsheet
 
ML-CheatSheet (1).pdf
ML-CheatSheet (1).pdfML-CheatSheet (1).pdf
ML-CheatSheet (1).pdf
 
R Cheat Sheet for Data Analysts and Statisticians.pdf
R Cheat Sheet for Data Analysts and Statisticians.pdfR Cheat Sheet for Data Analysts and Statisticians.pdf
R Cheat Sheet for Data Analysts and Statisticians.pdf
 
Matlab level 1.pptx
Matlab level 1.pptxMatlab level 1.pptx
Matlab level 1.pptx
 
Matlab tut3
Matlab tut3Matlab tut3
Matlab tut3
 
Commands list
Commands listCommands list
Commands list
 
purrr.pdf
purrr.pdfpurrr.pdf
purrr.pdf
 
Derivative investigation
Derivative investigationDerivative investigation
Derivative investigation
 
R Programming Reference Card
R Programming Reference CardR Programming Reference Card
R Programming Reference Card
 
02 linear algebra
02 linear algebra02 linear algebra
02 linear algebra
 
02 linear algebra
02 linear algebra02 linear algebra
02 linear algebra
 
R command cheatsheet.pdf
R command cheatsheet.pdfR command cheatsheet.pdf
R command cheatsheet.pdf
 
@ R reference
@ R reference@ R reference
@ R reference
 
Lesson 3
Lesson 3Lesson 3
Lesson 3
 
Reference card for R
Reference card for RReference card for R
Reference card for R
 
Short Reference Card for R users.
Short Reference Card for R users.Short Reference Card for R users.
Short Reference Card for R users.
 
1
11
1
 
1. Introduction.pptx
1. Introduction.pptx1. Introduction.pptx
1. Introduction.pptx
 
Y11+gdc+maximize+your+use+of+the++ev+2
Y11+gdc+maximize+your+use+of+the++ev+2Y11+gdc+maximize+your+use+of+the++ev+2
Y11+gdc+maximize+your+use+of+the++ev+2
 
matlab functions
 matlab functions  matlab functions
matlab functions
 

Mehr von Piyush Mittal

Mehr von Piyush Mittal (20)

Power mock
Power mockPower mock
Power mock
 
Design pattern tutorial
Design pattern tutorialDesign pattern tutorial
Design pattern tutorial
 
Reflection
ReflectionReflection
Reflection
 
Gpu archi
Gpu archiGpu archi
Gpu archi
 
Cuda Architecture
Cuda ArchitectureCuda Architecture
Cuda Architecture
 
Intel open mp
Intel open mpIntel open mp
Intel open mp
 
Intro to parallel computing
Intro to parallel computingIntro to parallel computing
Intro to parallel computing
 
Cuda toolkit reference manual
Cuda toolkit reference manualCuda toolkit reference manual
Cuda toolkit reference manual
 
Matrix multiplication using CUDA
Matrix multiplication using CUDAMatrix multiplication using CUDA
Matrix multiplication using CUDA
 
Channel coding
Channel codingChannel coding
Channel coding
 
Basics of Coding Theory
Basics of Coding TheoryBasics of Coding Theory
Basics of Coding Theory
 
Java cheat sheet
Java cheat sheetJava cheat sheet
Java cheat sheet
 
Google app engine cheat sheet
Google app engine cheat sheetGoogle app engine cheat sheet
Google app engine cheat sheet
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheet
 
Vi cheat sheet
Vi cheat sheetVi cheat sheet
Vi cheat sheet
 
Css cheat sheet
Css cheat sheetCss cheat sheet
Css cheat sheet
 
Cpp cheat sheet
Cpp cheat sheetCpp cheat sheet
Cpp cheat sheet
 
Ubuntu cheat sheet
Ubuntu cheat sheetUbuntu cheat sheet
Ubuntu cheat sheet
 
Php cheat sheet
Php cheat sheetPhp cheat sheet
Php cheat sheet
 
oracle 9i cheat sheet
oracle 9i cheat sheetoracle 9i cheat sheet
oracle 9i cheat sheet
 

Kürzlich hochgeladen

MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
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
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
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
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
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
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 

Kürzlich hochgeladen (20)

MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
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
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........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
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
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...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 

Matlab cheatsheet

  • 1. A Matlab Cheat-sheet (MIT 18.06, Fall 2007) Basics: save 'file.mat' save variables to file.mat load 'file.mat' load variables from file.mat Constructing a few simple matrices: diary on record input/output to file diary rand(12,4) a 12×4 matrix with uniform random numbers in [0,1) diary off stop recording randn(12,4) a 12×4 matrix with Gaussian random (center 0, variance 1) whos list all variables currenly defined zeros(12,4) a 12×4 matrix of zeros clear delete/undefine all variables ones(12,4) a 12×4 matrix of ones help command quick help on a given command eye(5) a 5×5 identity matrix I (“eye”) doc command extensive help on a given command eye(12,4) a 12×4 matrix whose first 4 rows are the 4×4 identity linspace(1.2,4.7,100) row vector of 100 equally-spaced numbers from 1.2 to 4.7 Defining/changing variables: 7:15 row vector of 7,8,9,…,14,15 x = 3 define variable x to be 3 diag(x) matrix whose diagonal is the entries of x (and other elements = 0) x = [1 2 3] set x to the 1×3 row-vector (1,2,3) x = [1 2 3]; same, but don't echo x to output Portions of matrices and vectors: x = [1;2;3] set x to the 3×1 column-vector (1,2,3) A = [1 2 3 4;5 6 7 8;9 10 11 12]; x(2:12) the 2nd to the 12th elements of x set A to the 3×4 matrix with rows 1,2,3,4 etc. x(2:end) the 2nd to the last elements of x x(2) = 7 change x from (1,2,3) to (1,7,3) x(1:3:end) every third element of x, from 1st to the last A(2,1) = 0 change A2,1 from 5 to 0 x(:) all the elements of x A(5,:) the row vector of every element in the 5th row of A A(5,1:3) the row vector of the first 3 elements in the 5th row of A Arithmetic and functions of numbers: A(:,2) the column vector of every element in the 2nd column of A 3*4, 7+4, 2-6 8/3 multiply, add, subtract, and divide numbers diag(A) column vector of the diagonal elements of A 3^7, 3^(8+2i) compute 3 to the 7th power, or 3 to the 8+2i power sqrt(-5) compute the square root of –5 exp(12) compute e12 Solving linear equations: log(3), log10(100) compute the natural log (ln) and base-10 log (log10) A b for A a matrix and b a column vector, the solution x to Ax=b abs(-5) compute the absolute value |–5| inv(A) the inverse matrix A–1 [L,U,P] = lu(A) the LU factorization PA=LU sin(5*pi/3) compute the sine of 5π/3 eig(A) the eigenvalues of A besselj(2,6) compute the Bessel function J2(6) [V,D] = eig(A) the columns of V are the eigenvectors of A, and Arithmetic and functions of vectors and matrices: the diagonals diag(D) are the eigenvalues of A x * 3 multiply every element of x by 3 x + 2 add 2 to every element of x Plotting: x + y element-wise addition of two vectors x and y plot(y) plot y as the y axis, with 1,2,3,… as the x axis A * y product of a matrix A and a vector y plot(x,y) plot y versus x (must have same length) A * B product of two matrices A and B plot(x,A) plot columns of A versus x (must have same # rows) x * y not allowed if x and y are two column vectors! loglog(x,y) plot y versus x on a log-log scale x .* y element-wise product of vectors x and y semilogx(x,y) plot y versus x with x on a log scale A^3 the square matrix A to the 3rd power semilogy(x,y) plot y versus x with y on a log scale x^3 not allowed if x is not a square matrix! fplot(@(x) …expression…,[a,b]) x.^3 every element of x is taken to the 3rd power plot some expression in x from x=a to x=b cos(x) the cosine of every element of x axis equal force the x and y axes of the current plot to be scaled equally abs(A) the absolute value of every element of A title('A Title') add a title A Title at the top of the plot exp(A) e to the power of every element of A xlabel('blah') label the x axis as blah sqrt(A) the square root of every element of A ylabel('blah') label the y axis as blah expm(A) the matrix exponential eA legend('foo','bar') label 2 curves in the plot foo and bar sqrtm(A) the matrix whose square is A grid include a grid in the plot figure open up a new figure window Transposes and dot products: x.', A.' the transposes of x and A x', A' the complex-conjugate of the transposes of x and A dot(x,y), sum(x.*y) …two other ways to write the dot product x' * y the dot (inner) product of two column vectors x and y x * y' the outer product of two column vectors x and y