1. Introducing MATLAB and the MATLAB Working Environment
Introduction
MATLAB is a platform for scientific calculation and high-level programming which uses an interactive environment that allows you to conduct complex calculation tasks more efficiently than with traditional languages, such as C, C++ and FORTRAN. It is the one of the most popular platforms currently used in the sciences and engineering.
MATLAB is an interactive high-level technical computing environment for algorithm development, data visualization, data analysis and numerical analysis. MATLAB is suitable for solving problems involving technical calculations using optimized algorithms that are incorporated into easy to use commands.
It is possible to use MATLAB for a wide range of applications, including calculus, algebra, statistics, econometrics, quality control, time series, signal and image processing, communications, control system design, testing and measuring systems, financial modeling, computational biology, etc. The complementary toolsets, called toolboxes (collections of MATLAB functions for special purposes, which are available separately), extend the MATLAB environment, allowing you to solve special problems in different areas of application.
In addition, MATLAB contains a number of functions which allow you to document and share your work. It is possible to integrate MATLAB code with other languages and applications, and to distribute algorithms and applications that are developed using MATLAB.
The following are the most important features of MATLAB:
It is a high-level language for technical calculation
It offers a development environment for managing code, files and data
It features interactive tools for exploration, design and iterative solving
It supports mathematical functions for linear algebra, statistics, Fourier analysis, filtering, optimization, and numerical integration
It can produce high quality two-dimensional and three-dimensional graphics to aid data visualization
It includes tools to create custom graphical user interfaces
It can be integrated with external languages, such as C/C++, FORTRAN, Java, COM, and Microsoft Excel
The MATLAB development environment allows you to develop algorithms, analyze data, display data files and manage projects in interactive mode (see Figure ).
Developing Algorithms and Applications
MATLAB provides a high-level programming language and development tools which enable you to quickly develop and analyze algorithms and applications.
The MATLAB language includes vector and matrix operations that are fundamental to solving scientific and engineering problems. This streamlines both development and execution.
With the MATLAB language, it is possible to program and develop algorithms faster than with traditional languages because it is no longer necessary to perform low level administrative tasks, such as declaring variables, specifying data types and allocating memory. In many cases, MATLAB eliminates the need for for loops. As a result, a line of MATLAB code usually replaces several lines of C or C++ code.
At the same time, MATLAB offers all the features of traditional programming languages, including arithmetic operators, control flow, data structures, data types, object-oriented programming (OOP) and debugging.
Figure shows a communication modulation algorithm that generates 1024 random bits, performs the modulation, adds complex Gaussian noise and graphically represents the result, all in just nine lines of MATLAB code.
MATLAB enables you to execute commands or groups of commands one at a time, without compiling or linking, and to repeat the execution to achieve the optimal solution.
To quickly execute complex vector and matrix calculations, MATLAB uses libraries optimized for the processor. For general scalar calculations, MATLAB generates instructions in machine code using JIT ( Just-In-Time ) technology. Thanks to this technology, which is available for most platforms, the execution speeds are much faster than for traditional programming languages.
MATLAB includes development tools , which help efficiently implement algorithms. Some of these tools are listed below:
MATLAB Editor used for editing functions and standard debugging, for example setting breakpoints and running step-by-step simulations
M-Lint Code Checker - analyzes the code and recommends changes to improve performance and maintenance (see Figure )
MATLAB Profiler - records the time taken to execute each line of code
Directory Reports - scans all files in a directory and creates reports about the efficiency of the code, differences between files, dependencies of files and code coverage
You can also use the interactive tool GUIDE ( Graphical User Interface Development Environment ) to design and edit user interfaces. This tool allows you to include pick lists, drop-down menus, push buttons, radio buttons and sliders, as well as MATLAB diagrams and ActiveX controls. You can also create graphical user interfaces by means of programming using MATLAB functions.
Figure shows a completed wavelet analysis tool (below) which has been created using the user interface GUIDE (above).
Data Access and Analysis
MATLAB supports the entire process of data analysis, from the acquisition of data from external devices and databases, pre-processing, visualization and numerical analysis, up to the production of results in presentation quality.
MATLAB provides interactive tools and command line operations for data analysis, which include: sections of data, scaling and averaging, interpolation, thresholding and smoothing, correlation, Fourier analysis and filtering, searching for one-dimensional peaks and zeros, basic statistics and curve fitting, matrix analysis, etc.
The diagram in Figure shows a curve that has been fitted to atmospheric pressure differences averaged between Easter Island and Darwin in Australia.
The MATLAB platform allows efficient access to data files, other applications, databases and external devices. You can read data stored in most known formats, such as Microsoft Excel, ASCII text files or binary image, sound and video files, and scientific archives such as HDF and HDF5 files. The binary files for low level I/O functions allow you to work with data files in any format. Additional features allow you to view Web pages and XML data.