Matlab Primer F
Only elementary computer programming skills are necessary to read and write
Matlabcode. The code is written in one file or a collection of files, called the
sourceorprogramfiles, using a standard file editor, such as thevieditor. The
source code includes the main program, also called a script, and the necessary
user-defined functions. The names of these files must be suffixed with.m
Execution begins by typing the name of the file containing the main
program in theMatlabenvironment. Alternatively, the code can be typed one
line at a time followed by theReturnkeystroke in theMatlabenvironment.
Matlabis an interpreted language, which means that the instructions
are translated into machine language and executed in real time, one at a time. In
contrast, a source code written inFortran, C, or C++ must first be compiled
to produce the object files, which are then linked together with the necessary
system libraries to produce the executable binary file.
F.1 Grammar and syntax.........................
Following is a list of general rules regarding the grammar and syntax ofMat-
lab. When confronted with an error after issuing a command or during execu-
tion, this list should serve as a first check point:
- Matlabvariables are (lower and upper) case sensitive:
The variableechidnais different than the variableechiDna. Similarly, the
Matlabcommandreturnis not equivalent to the erroneous command
Return; the latter will not be recognized by the interpreter. - Matlabvariables must start with a letter:
A variable name is described by a string of up to thirty-one characters
including letters, digits, and the underscore; punctuation marks are not
allowed. - Matlabstring variables are enclosed by a single quote:
For example, we may define the string variable:
thinker764 = ’Thucydides’