Sunteți pe pagina 1din 36

Mutlub 1utorlul for 8eglnners

Quun vung, LCSL, RPl


lLA Cruduute 1A for Sectlon
wungqcQrl.edu

* Locutlon: 'LC zcc
* Monduy: :cc - :cc
* 1uesduy: :cc - :cc
* lrlduy: :cc - :cc
My Cmce Eours
* lt ls u Progrummlng Lunguuge for Sclentlfc
Comutlng
* lt ls u Numerlcul Comutlng Lnvlronment where you
cun test or lmlement ulgorlthms
* lt ls u Softwure whlch runs on vlndowsjMuc CSjLlnux
vhut Mutlub ls?
* lt ls not used to develo hlgh emclency executuble
ullcutlons (comured wlth C, 'uvu, Python)
* Cenerully, lt cunnot be comlled (comured wlth C)
* Cenerully, we do not use lt for symbollc comututlon
(comured wlth Muthemutlcu und Mule)
vhut Mutlub ls not?
* Cet Mutlub
. Co to !"#$$"%&"' )"%* +"$,
htt:jjheldesk.rl.edujsetu.do
z. Softwure > Softwure to lnstull > Mutlub
. Cet the llcense wlth your RPl uccount
. Lownloud und lnstull
8efore Uslng Mutlub
* vlth your RPl Mutlub llcense, you ure not ullowed to use
Mutlub o cumus, unless you use vPN

* Your cun ulso use:
Scllub
lree, crosslutform, slmllur to Mutlub
lreemut
lree, crosslutform, slmllur to Mutlub
Python
lree, crosslutform, dlerent grummur, hlgh emclency,
vurlous llbrurles, oulur, cun be uckuged to .exe fles
Substltutes of Mutlub
* Sturt Mutlub, und you wlll see .
8eglnnlng wlth Mutlub
Menu bur
Ldltor
Commund wlndow
Current folder
vorksuce
Commund hlstory
* ln the commund wlndow, enter some communds or
exresslons, then ress -#."' key, see whut ls
dlsluyed ln commund wlndow, und whut huened
ln worksuce
* Semlcolon: do not dlsluy results lmmedlutely
Lxumle: Lnterlng communds und
exresslons
>> 1+2^3-4.3/6
ans =
8.2300

>> 1+2^3-4.3/6,
>> ans

ans =

8.2300
* ln Mutlub, dutu cun be reresented by vurlubles
* Luch vurluble hus u cusesensltlve vurluble nume,
whlch ls u comblnutlon of letters, dlglts, und
underscore churucters, beglnnlng wlth u letter
* lt ls ulwuys good for you to use reuduble vurluble
numes
vurlubles
>> a=3,
>> b=4,
>> bb=2,
>> bb2=a*b*bb

bb2 =

24
vurlubles
>> WldLh=3,
>> LengLh=4,
>> numberCf8ecLangles=2,
>> Area_All8ecLangles=WldLh*LengLh*numberCf8ecLangles

Area_All8ecLangles =

24
Anyone knows whut ls
he dolng here?
Nuturul lunguuge ullke
vurluble numes ure
much more reuduble!
Comure two leces of
Mutlub code, both of
whlch ure comutlng
t he t ot ul ur eu of
severul rectungles
* Understund the commund u=u
* Eow does the comuter execute thls commund
. Look ut the rlghthundslde "/*'"$$01#: u
z. Comute the exresslon: u
. Look ut the lefthundslde 2&'0&3%": u
. Asslgn the rlghthundslde exresslon to the
lefthundslde vurluble
* !"#"
. 8efore commund: u=
z. After commund: u=6
u=u?

>> u=

u =



>> u=u

u =

6
* clc: cleur commund wlndow
* cleur: remove ull vurlubles from memory
* cleur vur vurz .: remove lndlcuted vurlubles
* who: llst ull vurlubles ln memory
* .
vorksuce Communds
* Comlex numbers
* lf l und j ure not defned by user, they
ure the lmuglnury unlts.
* Rutlo of clrcle's clrcumference to
dlumeter
* l
Predefned Symbols
>> l

uns =

.cccc .ccccl

>> *j

uns =

.cccc .ccccl

>> l

uns =

.6
* Arruys cun be defned uslng squure bruckets
* Most functlons tuke urruysjmutrlces us lnut urguments
* !"#"

>> u=[c:c.:c.|

u =

c c.ccc c.zccc c.ccc

>> sln(u)

uns =

c c.c8 c.8, c.z
Arruys
* ex(x)
* sqrt(x)
* log(x)
* logc(x)
* cos(x)
* sln(x)
* tun(x)
* ucos(x)
* .
8ulltln lunctlons
* lot commund ls for druwlng zL llnes:
* !"#"
* >> x=[c:c.c:6|,
* >> y=sln(x),
* >> lot(x,y)
lot
* fgure: creute u new fgure wlndow
* hold on: enuble next lot to suerlmose on current
fgure
* hold o: enuble next lot to eruse current fgure
* grld: ut grld llnes on the lot
* tltle('text'): udd text ut the to on the lot
* xlubel('text'): udd text to xuxls
* ylubel('text'): udd text to yuxls
lot reluted communds
* Most of the tlme, you do not wunt to tye the
communds llne by llne, uguln und uguln
* lnsteud: wrlte ull communds ln one fle, und run lt ut
dlerent tlme
* Mfle: the scrlt of Mutlub code
Mfles!
* Menu bur > llle > New > Scrlt
* vrlte your code here
* Suve lt us u .m fle
Creute un Mfle
* Cne wuy:
* Rlght cllck your Mfle, choose Run
Run your Mfle
* Another wuy:
* Select the code you wunt to run, then rlght cllck, choose
Lvuluute Selectlon
Run your Mfle
* Comments ure llnes whlch ure not executed
* Comments begln wlth u ercent slgn
* Use two ercent slgns to hlghllght dlerent sectlons
of your code
Comments
Comments
* vhut lf you ure not sure where the roblem of the
code ls?
* Set u breukolnt, where your rogrum wlll sto for
you to check current vurlubles ln worksuce
Lebug
* Settlng u breukolnt

* Run the rogrum, und lt wlll sto before your
breukolnt (the commund on the breukolnt llne wlll
not be executed)
Lebug
* Contlnue runnlng
Lebug
* Coogle lt wlth key words!
Need hel?
!
#
* Mutlub roduct hel!
Need hel?
* Come to usk your 1A!
Need hel?
* lnstull Mutlub on your luto
* Pluy wlth slmle exresslons und communds
* vrlte some Mfles
* Leslgn und lot some zL curves (!"#" try to druw u
heurt)
Eomework

S-ar putea să vă placă și