1. Scripts or m-files are text files containing MATLAB code.
2. Editor is used to create a file containing the same statements written at command line.
3. Files are saved under a name ends with “.m”.
4. Both scripts and functions are created using MATLAB Editor.


1. A collection of commands that will be executed in command window.
2. Used for automate repetitive tasks.

3. Sequence of MATLAB commands is created in the Editor which will be saved as m-file.
4. Push the “Run” button to run a program.

5. Errors in code are displayed by some color symbols to right in the Editor.
6. An m-file will be opened or edited by using the open button in the toolbar.
7. An alternative is to type “Edit<name of m-file>” from Command window.


1. Operate on information (inputs) fed into them and return outputs.
2. Have a separate workspace and internal variables.
3. User-defined functions work the same as the built-in functions.
4. Function is defined by using following syntax:
function outputs = function_name (inputs)
% documentation
5. First line of a function starts with the keyword function.

6. It gives the function name and order of arguments.
7. To separate words lowercase is used, and not spaces.
8. Function can also be used as:

9. The name of the m-file and of the function should be the same.

10. In order to read the information of the function type “help<function name>” in the command window.




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s