Chapter 1
Introduction to MATLAB
1.1 Introduction
1.1.1 Book Organization
1.1.2 Chapter Organization
1.2 Starting MATLAB
1.3 Simple Calculations in MATLAB
1.3.1 Elementary Functions
1.4 Variables
1.4.1 Variable Types
1.5 Strings
1.6 Saving a Session and Its Variables
1.7 Input/Output Instructions
1.7.1 Formatted Output
1.7.2 Data Input
1.8 Help
1.8.1 Help Page
1.9 Concluding Remarks
1.10 Bibliography
1.1 Introduction
MATLABĀ® is a very high-level powerful system designed for technical computing. It integrates in the same software environment computation, programming, and visualization. It also has a very easy mathematical notation. Some of the most common applications for technical computing are as varied as:
Algorithmic development
Modeling and simulation
Data analysis
Plotting
Graphical User Interfaces
Rapid prototyping
Toolboxes
Vectorization
MATLAB is an acronym for MATrix LABoratory and it was originally developed to perform matrix calculations. MATLAB includes a programming language which is, probably, more powerful than traditional programming languages such as C, C++, C#, VisualBasic, and Python, to name a few.
MATLAB was developed in 1984 by Cleve Moler and Jack Little, who founded The MathWorks, Inc. in Natick, Massachusetts. The first version of MATLAB only had about eighty functions. The very latest version includes more than ten thousand functions.
Besides MATLAB, The MathWorks has developed a series of software packages, called toolboxes, written in the MATLAB programming language. These toolboxes can perform a number of calculations in several branches of engineering, economics, finance, physics, and mathematics, among others. It is hard to imagine an area of knowledge where MATLAB does not have an application. In the coming chapters we will use examples of the different areas where MATLAB has applications to illustrate how to use MATLAB.
1.1.1 Book Organization
The book is organized in the following way. The first two chapters are an introduction to MATLAB. The following three chapters, 3 to 5, cover basic calculations in MATLAB. The topics include linear algebra, calculus, and plotting. The next three chapters, 6 to 9, cover programming, advanced programming techniques, graphical user interface (GUI) development, and SimulinkĀ® which is a MATLAB-based GUI useful for system modeling and simulation. The last five chapters cover a broad set of examples illustrating applications in several engineering disciplines, physics, and finance.
1.1.2 Chapter Organization
The chapter is organized as follows. It begins with a MATLAB environment description. It describes the basic layout desktop and explains the purpose of the different windows available. It continues with basic calculations describing how to create and store variables. Different formats for variables are introduced. Basic functions are presented and the set of elementary function is described. Strings are introduced and some operations on strings are described. A very useful characteristic of MATLAB is the fact that all the variables, functions, and calculations are stored in the Command History and thus, they can be stored in a file, or a program can be created from them. This is covered in detail in this chapter. Finally, it is explained how to use MATLAB Help.
FIGURE 1.1: MATLAB main window.
1.2 Starting MATLAB
To install MATLAB, follow the instructions provided by The MathWorks, Inc. to install the software and the licenses. When the installation is finished, a MATLAB ico...