2.1 Arrays
2.2 Multidimensional Arrays-
2.3 Element-by-Element Operations
2.4 Matrix Operations
2.5 Polynomial Operations Using Arrays
2.6 Cell Arrays
2.7 Structure Arrays
2.8 Summary

The MATLAB sessions used scalar arithmetic to acquaint you with the MATLAB Command window, its Figure window, and a text editor window. In this we begin to explore MATLAB commands in more depth. One of the strengths of MATLAB is the capability to handle collections of numbers, called arrays, as if they were a single variable. For example, when we add two arrays A and B by typing the single command C = A + B, MATLAB automatically adds all the corresponding numbers -in .A and B to produce C. In most other
programming languages, this operation requires more than one command. The array-handling feature means that MATLAB programs can be very short. Thus they are easy to Create, read, and document.

The MATLAB array capabilities make it a natural choice for engineering problems that require a set of data analyzed. If you have been using a spreadsheet for data analysis, you may find that MATLAB is an-easier and more powerful tool for such work.

The array is the basic building block in MATLAB. We explain how to create, address, and edit arrays and how to use an important array operation, called element-by-element operation, to perform addition, subtraction, multiplication, division, and exponentiation to solve practical problems. We then introduce matrix operations, which are performed differently than element-by-element operations, and have their own applications. You probably have performed algebra with polynomials by hand. We explain how to use arrays in MATLAB to do polynomial algebra and root finding.

The following classes of arrays are now available in MATLAB 7:

numeric / character / logical / cell / structure / function handle / Java

 So far we have used only numeric arrays, which are arrays containing only numeric values. Within the numeric class are the subclasses single (single precision), double (double precision), int8, int16, and int32 (signed 8-bit, 16-bit, and 32-bit integers), and uint8, uint16, and uint32 (unsigned 8-bit, 16-bit, and 32-bit integers). A character array is an array containing strings. The elements of logical arrays are “true” or “false,” which, although represented by the symbols 1 and 0, are not numeric quantities. We will study the logical arrays .Cell arrays and structure arrays are covered in Sections 2.6 and 2.7 of this . Function handles are treated. The Java class is not covered in this text.

We introduce two new data structures: cell arrays and structure arrays. These data structures enable one array to store different types of data (for example, string data, real numbers, and complex numbers). With cell arrays you can access such data by its location, but with structure arrays you can access it by name also. This feature enables you to create and use databases having different types 0 information (for example, a list of people’s names, their addresses, and their phone numbers). We introduce these structures in Sections 2.6 and 2.7.

Share This