ام فایل متلب
MATLAB Function (*.m files) Editing, Executing and Displaying Help
MATLAB functions are just script files and must have the MATLAB extension "m", such as "circle.m".
- Editing MATLAB Function Files: Modifying or creating or saving MATLAB script function files, whether on PCs/Macs or Unix/Linux workstations, are edited the same way you normally edit files on those platforms:
- PCs/Macs: To create a new function run you favorite Edit application, select a "New" file, type in your MATLAB commands for the function, and "Save As" file name [function].m when finished. If the function script file already exists, that start with "OPEN File" instead.
- Unix/Linux workstations: To create a new script function or to modify an existing one type in the command of your favorite editor like vi, emacs or other with the name [function].m as argument, type in your MATLAB commands for the function, and save when finished. Editing can also be done on the Unix/Linux MATLAB command line using the bang escape "!", for example
Hint: Square brackets are used here to denote general items for the user as to type in actual names when actually used in MATLAB, such as "[function]", but in MATLAB square brackets are also used for marking arrays that are being initialized on assignment.
Hints : The percent sign "%" marks the beginning of a comment, so if a "%" appears in a line (except as a format specifier in a "fprintf" or "sprintf" argument, its other purpose), the rest of the line to the right is a comment, but the first set of lines marked at the beginning of the line before any MATLAB commands are Header lines that are listed when you use the MATLAB "help" command:
Hints: The semicolon ";" at the end of a MATLAB command line suppressed MATLAB output for that command, but semicolon are also used for separating rows in array initialization forms.
- Executing an Existing Function Files: In MATLAB, type the name of the function without the ".m" extension on the command line, for example for circle.m, type
- Displaying MATLAB Function Script File Content In MATLAB: On the MATLAB command line use the "type" command with the ".m" extension, for example,
- Sample MATLAB Function Script File: The simple example "circle.m should plot a unit circle when executed:
Web Source: http://www.math.uic.edu/~hanson/MATLAB/MATLABfunctions.html
Email Comments or Questions to firstname.lastname@example.org