Programming and Data Types    

M-File Programming


This chapter explains the basics of how to write script and function programs in M-files. It covers the following topics:
MATLAB Programming: A Quick Start
Creating MATLAB programs with M-files
Scripts
Simple M-file programs with no input or output arguments
Functions
M-files programs that accept input and return output
Subfunctions
Multiple functions within one M-file
Private Functions
Functions with limited visibility
Variables
Guidelines for creating variables; global and persistent variables; special values
Data Types
Description of all MATLAB data types
Operators
Arithmetic, relational, and logical operators
Keywords
Reserved keywords that you should avoid using
Flow Control
Statements that affect the flow of your code
String Evaluation
Executing user-supplied strings and constructing executable strings
Dates and Times
Date formats and functions that handle dates and times
Calling Functions
Making function calls with function or command syntax
Obtaining User Input
Obtaining input from a user during M-file execution
Subscripting and Indexing
Accessing and assigning to elements of a matrix
Empty Matrices
Matrices with at least one dimension equal to zero
Errors and Warnings
Reporting and recovering from errors that occur in your programs
Shell Escape Functions
Accessing your own C or Fortran programs using shell escape functions
Using MATLAB Timers
Scheduling the execution of MATLAB commands


  Programming and Data Types MATLAB Programming: A Quick Start