Nothing Special   »   [go: up one dir, main page]

MATLAB Intro

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

The MATLAB® is high-performance language for technical computing integrates

computation, visualization, and programming in an easy-to-use environment where problems


and solutions are expressed in familiar mathematical notation. Typical uses include

 Math and computation

 Algorithm development

 Data acquisition

 Modelling, simulation, and prototyping

 Data analysis, exploration, and visualization

 Scientific and engineering graphics

 Application development, including graphical user interface building

MATLAB is an interactive system whose basic data element is an array that does not require
dimensioning. It allows you to solve many technical computing problems, especially those
with matrix and vector formulations, in a fraction of the time it would take to write a program
in a scalar noninteractive language such as C or FORTRAN.

The name MATLAB stands for matrix laboratory. MATLAB was originally written to
provide easy access to matrix software developed by the LINPACK and EISPACK projects.
Today, MATLAB engines incorporate the LAPACK and BLAS libraries, embedding the
state of the art in software for matrix computation.

MATLAB has evolved over a period of years with input from many users. In university
environments, it is the standard instructional tool for introductory and advanced courses in
mathematics, engineering, and science. In industry, MATLAB is the tool of choice for high-
productivity research, development, and analysis.

MATLAB features a family of add-on application-specific solutions called toolboxes. Very


important to most users of MATLAB, toolboxes allow you to learn and apply specialized
technology. Toolboxes are comprehensive collections of MATLAB functions that extend the
MATLAB environment to solve particular classes of problems. You can add on toolboxes for
signal processing, control systems, neural networks, fuzzy logic, wavelets, simulation, and
many other areas

Key Features

 High-level language for technical computing


 Development environment for managing code, files, and data
 Interactive tools for iterative exploration, design, and problem solving
 Mathematical functions for linear algebra, statistics, Fourier analysis, filtering,
optimization, and numerical integration
 2-D and 3-D graphics functions for visualizing data
 Tools for building custom graphical user interfaces
 Functions for integrating MATLAB based algorithms with external applications and
languages, such as C, C++, Fortran, Java, COM, and Microsoft Excel

The MATLAB System

The MATLAB system consists of these main parts:

Desktop Tools and Development Environment

This part of MATLAB is the set of tools and facilities that help you use and become more
productive with MATLAB functions and files. Many of these tools are graphical user
interfaces. It includes: the MATLAB desktop and Command Window, an editor and
debugger, a code analyzer, and browsers for viewing help, the workspace, and folders.

Mathematical Function Library

This library is a vast collection of computational algorithms ranging from elementary


functions, like sum, sine, cosine, and complex arithmetic, to more sophisticated functions like
matrix inverse, matrix Eigen values, Bessel functions, and fast Fourier transforms.

The Language

The MATLAB language is a high-level matrix/array language with control flow statements,
functions, data structures, input/output, and object-oriented programming features. It allows
both "programming in the small" to rapidly create quick programs you do not intend to reuse.
You can also do "programming in the large" to create complex application programs intended
for reuse.
Graphics

MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as
annotating and printing these graphs. It includes high-level functions for two-dimensional and
three-dimensional data visualization, image processing, animation, and presentation graphics.
It also includes low-level functions that allow you to fully customize the appearance of
graphics as well as to build complete graphical user interfaces on your MATLAB
applications.

External Interfaces

The external interfaces library allows you to write C and FORTRAN programs that interact
with MATLAB. It includes facilities for calling routines from MATLAB (dynamic linking),
for calling MATLAB as a computational engine, and for reading and writing MAT-files.

Documentation

The MATLAB program provides extensive documentation, in both printable and HTML
format, to help you learn about and use all of its features.

The MATLAB documentation is organized into these main topics:

 Desktop Tools and Development Environment — Startup and shutdown, arranging


the desktop, and using tools to become more productive with MATLAB

 Data Import and Export — Retrieving and storing data, memory-mapping, and
accessing Internet files

 Mathematics — Mathematical operations

 Data Analysis — Data analysis, including data fitting, Fourier analysis, and time-
series tools

 Programming Fundamentals — The MATLAB language and how to develop


MATLAB applications

 Object-Oriented Programming — Designing and implementing MATLAB classes

 Graphics — Tools and techniques for plotting, graph annotation, printing, and
programming with Handle Graphics® objects

 3-D Visualization — Visualizing surface and volume data, transparency, and viewing
and lighting techniques

 Creating Graphical User Interfaces — GUI-building tools and how to write callback
functions

 External Interfaces — MEX-files, the MATLAB engine, and interfacing to Sun


Microsystems™ Java™ software, COM, Web services, and the serial port
There is reference documentation for all MATLAB functions:

 Function Reference — Lists all MATLAB functions, listed in categories or


alphabetically

 Handle Graphics Property Browser — Provides easy access to descriptions of


graphics object properties

 C and Fortran API Reference — Covers functions used by the MATLAB external
interfaces, providing information on syntax in the calling language, description,
arguments, return values, and examples

The MATLAB online documentation also includes

 Examples — An index of examples included in the documentation

 Release Notes — New features, compatibility considerations, and bug reports for
current and recent previous releases

 Printable Documentation — PDF versions of the documentation, suitable for printing

In addition to the documentation, you can access demos for each product from the Help
browser. Run demos to learn about key functionality of MathWorks™ products and tools.

Functions
Functions are evaluated element wise, as in the sin(t) example above. For example, if we type
>> t = linspace(0,4pi,9); then t is a vector containing 9 time samples. If we then type
>> x = sin(t), then MATLAB creates the vector x with 9 values corresponding to the sin of
each of the elements of the vector t, i.e. x = 0 1 0 -1 -0 1 0 -1 0

Operators
Since MATLAB generally deals with matrices, you must be careful when using operators like
“*” or “/”. If you want these operators to operate in an element-by-element fashion you have
to denote this by a leading period, e.g.“.*” and “./” !

Writing Programs in MATLAB


You can also write your own programs in MATLAB using any regular ASCII text editor.
Simply open a file with the extension .m (which is called an m-file) and edit line-by-line the
sequence of commands you want to include in your program. Save the file and execute the
program by typing the name of the file (without the .m) on your MATLAB command line.

Complex Numbers and Constants


Both i and j are defined by default to be sqrt(−1), unless you assign them to some other value.
Thus MATLAB can handle complex numbers. It also has many built-in variables:
>> x=2+3*j
>> y=pi

Control Flow in M-Files


MATLAB also provides the usual programming language commands for-end, if-else-break-
end and while-end. For example, try the following:
>> for c=1:2:12; disp(c); end;

Generating Matrices
MATLAB also provides several commands to generate matrices. Try out the following.
>> A = [1 2 3; 4 5 6; 7 8 9]
>> B = eye(3)
>> C = ones(2,3)
>> D = zeros(3,2)

You might also like