Anda di halaman 1dari 2

Instructions for using MATLAB

1. For lunching MATLAB, double click on the program icon, which is available on the window desktop. 2.MATLAB put ou in command window a!ter lunching it. "ommand window is the main window. #t is characteri$ed b MATLAB prompt % >>&. All commands, including those !or running user written programs, are t ped in this window at the MATLAB prompt. '(cept command window, MATLAB also have two separate windows. These are) Edit-window: This is where ou write, edit, create, and save our own programs in !ile called %M*!ile& or .m !ile. Graphic window or Figure window: The output o! all graphics commands t ped in the command window are !lushed to the graphics or Figure window. +. Creating, Saving and Executing a Script Fi e! .m fi e" A script !ile is a user created !ile with a se,uence o! MATLAB command in it. The !ile must be saved with a %.m& e(tension to its name, therb , making it an M*!ile. A script !ile is e(ecuted b t ping its name -without the %.m& e(tension. at the command prompt. Steps for creating a new .m file -i. /elect #e$ M%Fi e !rom the Fi e menu. A new edit window should appear. -ii. 0rit the MATLAB commands in the edit window. An line starting with 1 sign are interpreted as comment line b MATLAB and are ignored. -iii. /elect Save& Save As !rom Fi e menu. A dialog bo( should appear. T pe the name o! the document with e(tension o! .m and click Save. The document now saved in the current working !older. 2. Execution of a Script File) A /cript !ile is e(ecuted b t ping the name o! the !ile -without the %.m& e(tension.. #t is e,uivalent to t ping all the commands stored in the script !ile, one b one, at the MATLAB prompt. 3aturall , script !iles work on global variables, that is, variables currentl present the workspace. 4esults obtained !rom e(ecuting script !iles are le!t in the workspace. #! a MATLAB command is !inishes without a semicolon -5., then the result o! the command will be displa ed in the screen when we e(ecute the script !ile. Caution: 6 3ever name a script !ile the same as the name o! a variable it computes. 0hen MATLAB looks !or a name, it !irst searches the list o! variables in the workspace. #! a variable o! the same name as the script !ile e(ist, MATLAB will never be able to access the script !ile.

6 The name o! a script !ile must be begins with a letter. The rest o! the character ma include digits and underscore character. 7ou ma not use an periods -.. in the name other than the last one in %.m&. 6 Avoid name clashes with built*in*!unctions. #t good idea to !irst check i! a !unction or script o! the proposed name alread e(ists. 7ou can do this with the command exist-%!ile name&., which returns $ero i! nothing with name filename e(ist. 8. How to create MA !A" Function: A !unction !ile created !or developing a MATLAB !unction. A !unction !ile is also an %.m& !ile, e(cept that the variables in a !unction !ile are all local. Function !iles like programs or subroutines in ". A !unction !ile begins with a !unction de!inition line, which has a well*de!ined list i! inputs and outputs. 0ithout this line, the !ile becomes a script !ile. The s nta( o! the !unction de!inition line is as !ollows) function#output $aria%les& ' function(name)input $aria%les* 0here the !unction*name must be same as the !ilename -without the .m e(tension. in which the !unction is written. Caution: The !irst word in the !unction de!inition line, !unction, must be t ped in lower case. A common mistake to is t pe it as Function. More details about this re!er 9:etting started with MATLAB 8, b 4udra ;ratap, "h*2.2< =. At the end o! our Lab*class, trans!er all our script !iles !rom the work !older -i! it e(ist. and store it an other !older. 0henever ou re,uired these !iles -particularl the !unctions that ou have developed., >ust cop them to the work !older and use it. #! the !iles are not removed !rom the work !older then the !iles are compulsoril deleted be!ore start o! the ne(t Lab*"lass. ?. @eep a hard cop o! all our script !iles and output result o! ever MATLAB e(ercises that given to ou during our Lab*"lass. A. Attach the hard copies o! our script !ile and output result in our Lab*4ecord and submit it in ever Lab*"lass !or signature. B. Be!ore leaving the terminal, properl close the MATLAB window.

Anda mungkin juga menyukai