0% found this document useful (0 votes)
39 views2 pages

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
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views2 pages

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
We take content rights seriously. If you suspect this is your content, claim it here.
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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy