0 ratings0% found this document useful (0 votes) 25 views3 pagesMATLAB Cheat Sheet 2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
A MathWorks:
MATLAB® Basic Functions Reference
ele ‘lear command window : Define variable @ with value §
help fun Display inne help for fun R= 223; 454 | DelineAara 2x3 matrix
‘goo fon mn documentation for fam aea23 “space” seporates columns
Open documentation fr fe ase “for new ine separates rows
Toad( "filename", "vars") lood variables rom saat file
2) ‘Concatenate arays horizontally
‘wlimpore("ELlenane’) (Open interaeive impor tool am < i
E encalenate areys vera
‘illename" "vars") Save variables to fe sane?
x@ = 7 Change Ath element of x10 7
= Remove iems from workspace
aaa) = 5 Change Alla} 105
script Run he scrip fle named
fee re (5:10) {Get Sth to 10h elements ofx
Format style Set output deplay formar nd) ‘Get every 2nd element of x [sto lox
Ser Ge lat of stad toolboxes 058) Uist oloments greater than 6
Gees Sian end top ner e101 ‘Change elements wing con
cenite ‘Abor the evrrent ealevlaion ne Gedtrrow fA
ae) {Get 3rd column of A
retin 6th row of A
en NE, 25) Get nd 0 Sth
tod ‘Marx math operations AGT TD=[Link] ED | Swap the 1st and 7th column
a ‘Avray mulipliction and division a [o.o41, 42, een) wih gens
[olementwise operations) edo ‘Create regularly spaced vector with
Matix and antay power spacing ds
V Left division linear optimization Linspace(a,b.n) {Creole vector af» equally spaced values
‘Neral and complex conivgaie Segepace(a,b.=) ‘Create vector of m logarithmically spaced
transpose values
=a. =r <>) = OF | Relational operators zeroa(n.a) ale m xn matrix of zeros
ee, II, = HOF Topical operations ‘ones(e,n) Creole mx n matrix of ones
AND, 08, NOT, XOR) ever) {Create @n xn identity matrie
2 ‘Suppress ovat display ediagte) Creole diagonal matrix from vector
‘Connect ins (vith break) zediag@) Get diagonel cloments of matix
-siption Comment eshgridtxy) {Creole 20 ond 30 grids
Deliniion of @ character vector ‘and(ayn), andi Creole uniformly distributed random
“This i = string” | Definiion of e sting numbers or integers
ss fond ane ‘andbe a) nore rbd don
Special Variables and Constants en
ane Mos recot answer ide te Imaginary ont
a3 1592654 reatle) Real prt of complex number
now mapiary writ =) Imapiory par of complex avaber
Nan, nen Note number fe, divin by 20) aagie(=) have angle in raions
Taf, int ininy coniteh Elemis complex conjugate
oe Flooingpoin late eccvoey dereal(e) Determine wheter eray i rel
TaeA MathWorks:
Ts
‘sinte)y asin Sie ond invecve (erument in ean) plotie.y binespec) A y vx
‘nd(s), asind Sine and inverse (orgument in degrees Line ey Tiere» el of
siah(a), asian Hyperbolic in and inverse (ag. Marker: Linestyle, marker, ond
radians feet n a & | colorarasting
“Analogous forthe ake tigonometri uncon: Colors Exanple:
ea a tan wdat Fig, bs crm ys kw | red soli line wihou! markers
abs (x) Absolute value of x, complex magnitude ‘title("title") ‘Add plot title
e700) Exponential of x Tegend("iat, “Zaa") ‘Add legend fo ones
sart(n), nthrootOwind | Square oot, ral nih root ofreal numbers | | X/v/eiabed ("aber ‘ald x/y/s xi label
Tose) Natural logarithm of xly/eticks(ecksvec) | Get ors x/y/2 ai fcks
‘esa, esi Logarithm with base 2 and 10, respecively | | x/y/sticklabele(labels) | Get or se! »/y/z ons ck label
‘factorial(n) Factorial of n x/y/ztickangle(angle) Rotate x/y/z axis tick labe
‘sign Signofx x/yi=iim Get or set x/y/2 axis ange
Bodina) Remainder eer dvision nodule) =ie(Lim), exis style | Set exis lms ond syle
seit), Fix, Floor | Round foward sin anf cent (nye) dt
Found) Round to nearest decimal or neger grid on/ott Show ons gid
hold on/oft Retain the cure’ plot when
ceding new pot
aaa: ro nse aon
table(var,..,vazi) Creole able fom data in verables | |_t2edlayout tm m)
vert vor yyaxis left/right Create second yon
‘eadtable('#ile") Creole lable fom He igure Creole gure window
array2tabie() Convert numeric erate table wf, ace Get cron figure, get eurent ex.
Twas Exeet dota from variable vor ag Cleor cure figure
Crest @ new fable wih spoctiod Close open figures
rows and columns trom T
‘Assign deta to new) column in T ‘Common Plot Types
‘Access properies of T
‘categoricaliay (Create © categorical array nO SA R=
‘sunmazy(®), gzoupsunmary | Prin summary of fable
joiner, 12) Join fables wih common variables
ive Editor tsk ore apps that can be added to « lve script o intracively
perform o specific st of operations, Tasks represen a series of MATLAB
‘commands, To see the commands thatthe task runs, show the generated
code.
‘Common tasks available from the Live Editor tab on the
dleskop tooltip:
+ Clean Misting Bote + Cleon Outer
+ Find Change Points + Find Loca Exema
Flot Gallery: mathwrks com/prodvci/maab/plogalln
+ Remove Trends + Smooth Data e peel
Tae@A MathWorks:
“Accelerating he pace of engineering and rience
2engEhO) tergh f lege ray dimension rm peed
cor) ‘ray dimensions sax), ain, bounds
runes) Nnbor of elomens in evar ean(a), median, mode | Siasical peratins
sere) Sort ray slomente wea, var Stender devon end vrs
sortrors(a) | Ser tows of erey or able oveunihn), BoverOS, | Marin sacl fnetans
‘sina Flip order of elements i ery sovnes, movniny |__| 87 lena moving window
saueess(0) | Remove dimensions of nah 1 Eevee, novver
[Link]) | Reshope aay comson(i), compred, | Canulove sae ncons
‘repmatiA.n) Repeat copies of array commen, connin
any), 22, ‘Check if any/all elements are nonzero smootndaca(a) Smooth noisy dete
rr ee ee Bieeeounea te) Cele isogran bin com
find(a) Indices and values of nonzero elements: sorecoee (A), cov Correlation cooticions, coveriance
sorry x07 Cesscoreaton cestcoverinee
cw Ail normalize) Normalize daa
— a detrendia) Remove pelynonial vend
Taos hier Find eters in doe
teacelal Sum of dagoal denen of ma
ase) Bateman of mai
cig), cigs Eigenvalues and vectors of matrix (subset) Declore symbolic variable
inva, piaw Inverse and pseudo inverse of matrix eae ym ta tb Define ¢ symbolic equation
ee Noosa solve aqne ware) Sole syle expresion
=xe(h), Team) | Mavis ponenel and logan ee ieee
sone ie prove cadens Een bse in
soe B) Dot predvet factor(expr) Factor ‘boli
kxon(A,B) Kronecker tensor product ree
ont tent: aE HinplifylexPe) Simply smnbeleexeresion
= Ne ne ones ——— Gerune(variasrsapeion) | Male enunpon for veeble
"120, txis | Lower and upper Wriangulor pat of malix seeuapttons(s) see saree et
Tinsolveta.8) | Sve Inear so ofthe fo AXS3 Zplottexpe, Foontoar, | ting fnctons for
eaminnorm(A8) | Leestgvores oho nea evan fevct, foots, implicit | symbole cxprenions
GEO, 15, cho | Matix deconpostons didtiespewerad Dire smbokewxpreion
eran) Singular vee deconposion dsoive(aegn cond) Sele diferenl
sevain8) Generalized SYD teveton smoky
= ead Tnbteapeveiay Bi neg symbole expression
calor tten at) Tere expansion of feton
*requires Symbolic Math Toolbox
aed
(©2074 The Mas, nc MATAR od Simao erred aden The Maho, Se maths com/hadonr lo it of obra odors,
‘herpes rand nan mayb anon creamed vsemans oar repair,