INTRODUCTION TO MATLAB
1.1 OBJECTIVES
a. To Know the history and features of MATLAB
b. To Know the local environment of MATLAB
1.1.1 CONTENT
Introduction
MATLAB is a high-level language and interactive environment for numericalcomputation,
visualization, and programming. Using MATLAB, you can analyse data, develop algorithms,
and create models and applications. The language, tools, and built-inmath functions enable
you to explore multiple approaches and reach a solution fasterthan with spread sheets or
traditional programming languages, such as C/C++ or Java. You can use MATLAB for a
range of applications, including signal processing andcommunications, image and video
processing, control systems, test and measurement, computational finance, and computational
biology. More than a million engineersandscientists in industry and academia use MATLAB,
the language of technical computing.
History
Developed primarily by Cleve Moler in the 1970'sDerived from FORTRAN
subroutines LINPACK and EISPACK, linear and eigenvaluesystems.
Developed primarily as an interactive system to access LINPACK and EISPACK.
Gained its popularity through word of mouth, because it was not socially distributed.
Rewritten in C in the 1980's with more functionality, which include plotting routines.
The Math Works Inc. was created (1984) to market and continue development of
MATLAB.
Strengths
MATLAB may behave as a calculator or as a programming language
MATLAB combine nicely calculation and graphic plotting.
MATLAB is relatively easy to learn
MATLAB is interpreted (not compiled), errors are easy to fix
MATLAB is optimized to be relatively fast when performing matrix operations
MATLAB does have some object-oriented elements
Weaknesses
MATLAB is not a general purpose programming language such as C, C++, or
FORTRAN
MATLAB is designed for scientific computing, and is not well suitable for other
applications
MATLAB is an interpreted language, slower than a compiled language such as C++
MATLAB commands are specific for MATLAB usage. Most of them do not have a
direct equivalent with other programming language commands
Competition
One of MATLAB's competitors is Mathematica the symbolic computation
program.MATLAB is more convenient for numerical analysis and linear algebra. It is
frequentlyused in engineering community. Mathematica has superior symbolic manipulation,
making it popular among physicists.
There are other competitors: Scilab, GNU Octave, and Rlab
Key Features
It is a high-level language for numerical computation, visualization and application
development.
It also provides an interactive environment for iterative exploration, design and
problem solving.
It provides vast library of mathematical functions for linear algebra, statistics, Fourier
analysis, filtering, optimization, numerical integration and solving ordinary differential
equations.
It provides built-in graphics for visualizing data and tools for creating custom plots.
MATLAB's programming interface gives development tools for improving code
quality, maintainability, and maximizing performance.
It provides tools for building applications with custom graphical interfaces.
It provides functions for integrating MATLAB based algorithms with external
applications and languages such as C, Java, .NET and Microsoft Excel.
MATLAB's Power of Computational Mathematics
MATLAB is used in every facet of computational mathematics. Following are some
commonly used mathematical calculations where it is used most commonly:
Dealing with Matrices and Arrays
2-D and 3-D Plotting and graphics
Linear Algebra
Algebraic Equations
Non-linear Functions
Statistics
Data Analysis
Calculus and Differential Equations
Numerical Calculations
Integration
Transforms
Curve Fitting
Various other special functions
Uses of MATLAB
MATLAB is widely used as a computational tool in science and engineering encompassing
the fields of physics, chemistry, math and all engineering streams. It is used in a range of
applications including:
Signal processing and Communications
Image and video Processing
Control systems
Test and measurement
Computational finance
Computational biology
Understanding the MATLAB Environment
MATLAB development IDE can be launched from the icon created on the desktop. The
main working window in MATLAB is called the desktop. When MATLAB is started, the
desktop appears in its default layout:
The desktop includes these panels:
Current Folder - This panel allows you to access the project folders and files.
Command Window - This is the main area where commands can be entered at the commandline. It is
indicated by the command prompt (>>).
Workspace - The workspace shows all the variables created and/or imported from files.
Command History - This panel shows or rerun commands that are entered at the
commandline.
You are now faced with the MATLAB desktop on your computer, which contains the
prompt (>>) in the Command Window. Usually, there are 2 types of prompt:
>>For full version
EDU> for educational version
Note:
1. To simplify the notation, we will use this prompt, >>, as a standard prompt sign, though
our MATLAB version is for educational purpose.
2. MATLAB adds variable to the workspace and displays the result in the Command
Window.
Managing workspace and file commands
Command Description
cd Change current directory
clc Clear the Command Window
clear (all) Removes all variables from the workspace
clear x Remove x from the workspace
copy file Copy file or directory
delete Delete files
dir Display directory listing
exist Check if variables or functions are defined
help Display help for MATLAB functions
look for Search for specified word in all help entries
mkdir Make new directory
move file Move file or directory
pwd Identify current directory
rmdir Remove directory
type Display contents of file
what List MATLAB files in current directory
which Locate functions and files
who Display variables currently in the workspace
whos Display information on variables in the workspace
Commonly used Operators and Special Characters
MATLAB supports the following commonly used operators and special characters:
Operator Purpose
+ Plus; addition operator.
- Minus; subtraction operator.
* Scalar and matrix multiplication operator.
.* Array multiplication operator.
^ Scalar and matrix exponentiation operator.
.^ Array exponentiation operator.
\ Left-division operator.
/ Right-division operator.
.\ Array left-division operator.
./ Array right-division operator.
: Colon; generates regularly spaced elements and represents an
entire row or column.
() Parentheses; encloses function arguments and array indices;
overrides precedence.
[] Brackets; enclosures array elements.
. Decimal point.
… Ellipsis; line-continuation operator
- Quote sign and transpose operator.
._
Non-conjugated transpose operator.
= Assignment operator.
, Comma; separates statements and elements in a row
; Semicolon; separates columns and suppresses display.
% Percent sign; designates a comment and specifies formatting.
Note:
If you end a statement with a semicolon, MATLAB performs the computation, butsuppresses
the display of output in the Command Window.
Special Variables and Constants
MATLAB supports the following special variables and constants:
Name Meaning
ans Most recent answer.
eps Accuracy of floating-point precision.
i,j The imaginary unit √-1.
Inf Infinity.
NaN Undefined numerical result (not a number).
pi The number π
Naming Variables
Variable names consist of a letter followed by any number of letters, digits or underscore.
MATLAB is case-sensitive.
Variable names can be of any length; however, MATLAB uses only first N characters, where
N is given by the function namelengthmax.