Page 43 - A Guide to MATLAB for Beginners and Experienced Users
P. 43

24        Chapter 2: MATLAB Basics


                       The result is a 3 × 1 matrix, in other words, a column vector.
                      MATLABhas many commands for manipulating matrices. You can read
                       about them in the section More about Matrices in Chapter 4 and in the online
                       help; some of them are illustrated in the section Linear Economic Models in
                       Chapter 9.


           Suppressing Output


                     Typing a semicolon at the end of an input line suppresses printing of the
                     output of the MATLAB command. The semicolon should generally be used
                     when defining large vectors or matrices (such as X = -1:0.1:2;). It can
                     also be used in any other situation where the MATLAB output need not be
                     displayed.


           Functions


                     In MATLAB you will use bothbuilt-in functions as well as functions that you
                     create yourself.

           Built-in Functions

                     MATLAB has many built-in functions. These include sqrt, cos, sin, tan,
                     log, exp, and atan (for arctan) as well as more specialized mathematical
                     functions suchas gamma, erf, and besselj. MATLAB also has several built-
                                                                                         √
                     in constants, including pi (the number π), i (the complex number i =  −1),
                     and Inf (∞). Here are some examples:
                       >> log(exp(3))


                       ans =
                             3

                     The function log is the natural logarithm, called “ln” in many texts. Now
                     consider

                       >> sin(2*pi/3)

                       ans =
                             0.8660
   38   39   40   41   42   43   44   45   46   47   48