ABSTRACT

For the various control structures, the MATLAB programming language makes use of a special data type called a logical. This chapter introduces background information about logicals, and then it is put to use with control structures. Logicals are a different data type than numbers and text. They are a data type that can only have a value of either TRUE or FALSE. Because there are only two possible values, MATLAB designates logicals as a specific data type. Besides executing mathematical operations, MATLAB can execute logical operations. By convention, when MATLAB executes a logical expression, the result is the value 1 when TRUE and the value 0 when FALSE. The MATLAB function strcmp can be used to compare entire strings. Functions can also be created and written in a MATLAB m-file by following the necessary scripting constructs and syntax. In order to call the created function, it should be located in the current folder of MATLAB.