0% found this document useful (0 votes)
33 views

7 Useful Tips Using MATLAB

The document provides 7 useful tips for using MATLAB commands. The tips include using the up arrow key to re-use previous commands, cleaning the command window with 'clc', assigning names to matrices and commands for later use, viewing and modifying matrices in the workspace, merging matrices horizontally and vertically, transposing vectors, and extracting rows and columns from matrices.

Uploaded by

Aditya Sidharta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

7 Useful Tips Using MATLAB

The document provides 7 useful tips for using MATLAB commands. The tips include using the up arrow key to re-use previous commands, cleaning the command window with 'clc', assigning names to matrices and commands for later use, viewing and modifying matrices in the workspace, merging matrices horizontally and vertically, transposing vectors, and extracting rows and columns from matrices.

Uploaded by

Aditya Sidharta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

7usefultipsyouwanttoknowinusingMATLABcommands

PreparedbyProfVictorTan

1. Usetheuparrowkey()toreuseormodifyacommand(especiallylongcommand).Youcan
keeppressingonthiskeytorecoverthepreviouscommandsthatyouhavetyped.
2. Youcancleanupthecommandwindowusingtheclccommand.Notethatyoucanstillrecover
thepreviouscommandsusingthe()keyafterthecleanup.
3. Itsalwaysgoodtogiveyourmatrixorcommand(whichgivesamatrixasanswer)aname.e.g.
>>B=rref(A)(insteadofjusttypingrref(A)aftertheprompt)
Ifyourealizethatyouhaveforgottentoassignanametoyourpreviouscommand,youmaystill
dosointhenextimmediatecommandpromptbytyping
>>C=ans(whereCisthenamechosenbyyou,andansisthematrixthatcomesfromthe
immediatepastcommand)
4. Allthecontentofthematricesthatyouhavenamedwillbestoredintheworkspacewindow
(seediagrambelow)
Ifyouwanttochangeafewentriesofa(huge)matrix,butdonotwanttotypethewholematrix
again,youcanlookforthenameofthatmatrixintheWorkspaceandclickonit.Anew
Variableswindowwillappearthatallowsyoutomodifytheentriesaccordingly.
Note:Ifyoutypeclearinthecommandwindow,allthematricesstoredintheworkspacewill
bedeleted.

ClickonthematrixAin theworkspacewillrevealitsentriesina
newVariableswindow,whichallowsyoutochangethevaluesof
theindividualentries.Youmayclosethewindowafteryouhave
madethenecessarychanges.

5. Youcanmerge(horizontally)twoormorematricesA,B,C,,Zallhavingthesamenumberof
rowstoformasuperaugmentedmatrixbytyping
>>[ABCZ](Nocommasorverticallinesbetweenthematrices.Thesematricescanbe
columnvectors.)

Similarly,youcanmerge(vertically)twoormorematricesA,B,C,,Zallhavingthesame
numberofcolumnstoformastackedupmatrixbytyping
>>[A;B;C;;Z]
6. Ifyoumistakenlytypeacolumnvectorvasarowvectororviceversa,insteadofretyping,you
canusethetranspose:
>>v=v(thiswillchangevfromrowtocolumn,orcolumntorow)
7. Ifyouwanttogetaspecificrow(orcolumn)ofamatrixthathasbeentyped,youcantype
>>r=A(2,:)(ThiswillgiveyouthesecondrowofA;hereristhenamechosenbyyou.)
>>c=B(:,3)(ThiswillgiveyouthethirdcolumnofB;herecisthenamechosenbyyou.)

You might also like