MATLAB is a language for technical computation. It includes computation, visualization, and programming in a single environment where problems and solutions are expressed in familiar mathematical notation. Matlab is mainly used in the following areas: · Math and computation · Algorithm development · Modeling and simulation · Data analysis, exploration, and visualization · Application development, including graphical user interface building The basic data element of MATLAB is an array that does not require dimensioning. This allows us to solve many technical computing problems, especially those with matrix and vector formulations due to which it is faster than the conventional programming languages such as C. MATLAB features a family of application-specific solutions called toolboxes. Toolboxes allows us to learn and apply specialized technology. Toolboxes are comprehensive collections of MATLAB functions (M-files) that extend the MATLAB environment to solve particular classes of problems. Areas in which toolboxes are available include signal processing, control systems, neural networks, fuzzy logic, wavelets, simulation, and many others. MATLAB basically consists of five main parts: 1. Development Environment: This is the set of tools and facilities that help us to use MATLAB functions and files. Many of these tools are graphical user interfaces. It includes the MATLAB desktop and Command Window, a command history, and browsers for viewing help, the workspace, files, and the search path. 2. MATLAB function library: This 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 eigenvalues, Bessel functions, and fast Fourier transforms. 3. MATLAB Language: This 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 and dirty throw-away programs, and “programming in the large” to create complete large and complex application programs. 4. Handle Graphics: This is the MATLAB graphics system. It includes high-level commands for two-dimensional and three-dimensional data visualization, image processing, animation, and presentation graphics. It also includes low-level commands that allow us to fully customize the appearance of graphics as well as to build complete graphical user interfaces on MATLAB applications. 5. MATLAB Application Program Interface (API): This is a library that allows us to write C and FORTRAN programs that interact with MATLAB. It include facilities for calling routines from MATLAB (dynamic linking), calling MATLAB as a computational engine, and for reading and writing MAT-files. Development Environment: The most significant part of Development Environment is MATLAB’s desktop tools. We can also use MATLAB functions to perform most of the features found in the desktop tools. The most commonly used desktop tools are: • Command Window – It is used to enter variables and run functions and M-files. • Command History - In the Command History, we can view previously used functions, and copy and execute selected lines. • Launch Pad – It provides easy access to tools, demos, and documentation. • Help Browser - To search and view documentation for all Math Works product. • Current Directory Browser - MATLAB file operations use the current directory and the search path as reference points. Any file we want to run must either be in the current directory or on the search path • Workspace Browser - The MATLAB workspace consists of the set of variables (named arrays) built up during a MATLAB session and stored in memory. • Array Editor - To view and edit a visual representation of one- or two-dimensional numeric arrays, strings, and cell arrays of strings that are in the workspace. • Editor/Debugger - Editor/Debugger is used to create and debug M-files, which are programs we write to run MATLAB functions. The Editor/Debugger provides a graphical user interface for basic text editing, as well as for M-file debugging. Programming with MATLAB: Flow Control: MATLAB has several flow constructs for example: if statements, switch statements, for loops, while loops, continue statements, break statements. Apart from flow constructs it has other data structures for example multidimensional arrays, cell arrays, characters and text, structures. MATLAB is a powerful programming language as well as an interactive computational environment. Files that contain code in the MATLAB language are called M-files. We create M-files using a text editor, then use them as we would any other MATLAB function or command. There are two kinds of M-files: • Scripts, which do not accept input arguments or return output arguments. They operate on data in the workspace. • Functions, which can accept input arguments and return output arguments. Internal variables are local to the function.
Indian Institute of Technology, Kharagpur
Institute of Engineering and Technology Lucknow
Indian Institute of Technology Kanpur
IIT Patna, IIT kharagpur