Using the C++ Math Library    

MATLAB Basics

This section contains an overview of the MATLAB language and programming environment. It does not substitute for a thorough reading of Using MATLAB, but it does describe most of the basic concepts in MATLAB. Most of the material in this section, and in this chapter, is repeated and elaborated on in subsequent chapters.

This section describes the interpreted MATLAB environment, not the MATLAB C++ Math Library. Understanding the material in this section will help you understand why the MATLAB C++ Math Library works the way it does.

MATLAB's central data type is the array. Using the MATLAB interpreter, you can create array variables, form arithmetic expressions with arrays, and call functions on arrays. In addition, you can print arrays to and read arrays from files and the screen.

Most of the built-in MATLAB functions and operators are vectorized, that is, they operate on entire arrays. For example, to add one array to another, instead of writing a doubly nested for-loop, as you would in C or Fortran, you simply call MATLAB's + operator. Similarly, to compute the square root of all the elements in an array, don't loop through the array elements individually calling sqrt() on each one. Instead, call sqrt() on the entire array; sqrt() loops for you.

MATLAB programs consist of a collection of functions. Each MATLAB file can store one or more functions; the filename must end with the extension .m (hence the name M-files). The primary function in each M-file must have the same name as the file itself.


 Fundamentals Data Types