29-05-2013, 11:37 AM
An Introduction to MATLAB
MATLAB.ppt (Size: 1.76 MB / Downloads: 32)
What is MATLAB?
MATrix LABoratory: MATLAB is a program for doing numerical computation. It was originally designed for solving linear algebra type problems using matrices. It’s name is derived from MATrix LABoratory.
The basic building block for the MATLAB is matrix. The fundamental datatype is the array. Vectors , scalars, real matrices, and complex matrices are all automatically handled as special cases of the basic datatype.
The build-in functions are optimized for vector operations.
Strengths of MATLAB
MATLAB is relatively easy to learn
MATLAB code is optimized to be relatively quick when performing matrix operations
MATLAB may behave like a calculator or as a programming language
MATLAB is interpreted, errors are easier to fix
Although primarily procedural, MATLAB does have some object-oriented elements
Weaknesses of MATLAB
MATLAB is NOT a general purpose programming language
MATLAB is an interpreted language (making it for the most part slower than a compiled language such as C++)
MATLAB is designed for scientific computation and is not suitable for some things (such as parsing text)
MATLAB Variable Names
Variable names ARE case sensitive.
Variable names can contain up to 63 characters (as of MATLAB 6.5 and newer).
Variable names must start with a letter followed by letters, digits, and underscores.
Dimensioning of variables are automatic in MATLAB.
The fundamental datatype of variables is array.
A semicolon at the end of the every command suppressses the screen output, except for graphics and on-line help commands.
Output format:
format short; 31.4159;
format long; 31.41592653589793
User-Defined Function
User-defined functions are stored as M-files. Each must start with a function definition line that contains
the word “function”,
a variable that defines the function output,
a function name, and
a variable used for the input argument.
Some examples:
function output = my_function(x)
function result = calculation(a)
Hints: The function name and the names of the input and output variables are arbitrary and selected by the programmer, but the word “function” can not be changed.