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
**>> !vi [function].m**

*
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:
*

>> help [function]

>> lookfor [keyword]

*
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.
*

>> circle

>> type circle.m

% Circle - Script file to draw unit circle % modified from "Getting Started with MATLAB" by Rudra Pratap 9/14/94 format compact % tightens loose format format long e % makes numerical output in double precision theta = linspace(0,2*pi,100); % create vector theta x = cos(theta); % generate x-coordinate y = sin(theta); % generate y-coordinate plot(x,y); % plot circle axis('equal'); % set equal scale on axes per pixel title('Circle of unit radius') % put title c=2*pi % prints out 2*pi value disp('end circle.m') % prints out literal string. % End Circle

**Email Comments or Questions to
hanson@uic.edu**