Page 16 - Computational Colour Science Using MATLAB
P. 16

WHY BASE THIS BOOK UPON MATLAB?                      3
             and demonstrated with clarity and accuracy. Moreover, the computation of
             many colorimetric terms is ideally suited to a language that expresses variables in
             terms of matrices and vectors. Some procedures are best explained or
             implemented using loops, however, and for these situations MATLAB provides
             for and while looping structures.
               The second strength of MATLAB is that it includes an encyclopaedic
             collection of subprograms, called M-files, for the solution of nearly any
             numerical problem. Although this book is not principally concerned with generic
             numerical analysis, but rather with particular colorimetric algorithms, the M-
             files that are available with MATLAB are useful for many computations in
             colour science. MATLAB provides many functions (such as those with the
             ability to invert matrices) and if it was necessary to spend time explaining these in
             detail or writing code to implement them it would detract from the main focus of
             this book, which is colour science. The reader may wish to refer to other
             textbooks (e.g. Press et al., 1993) that address implementations of numerical
             analysis in programming languages such as C if they wish to convert the code in
             this book into other programming languages.
               MATLAB’s most spectacular feature is its capability to display graphics. Two-
             or three-dimensional graphs are easily constructed by even a novice MATLAB
             user. Thus


                  x = [1 2 3 4 5];
                  y = [3 5 7 9 11];
                  plot(x,y)

             is sufficient code to plot a graph of the five values in the vector y against those in
             the vector x. Experienced programmers will find it trivial to construct
             sophisticated and informative graphs, and the ability to almost effortlessly
             visualize data is one of main advantages of using MATLAB in a research
             environment. MATLAB allows the user to answer complex ‘what if?’ questions
             with just a handful of code lines.
               MATLAB can be confusing, however, for new users who do not have a
             reasonable understanding of linear algebra. For this reason, Chapter 3
             provides a gentle introduction to MATLAB and Chapter 2 provides a basic
             introduction to linear algebra and the notation that is used throughout this
             book. Where possible the code that is presented has been written for clarity
             rather than for efficiency or speed of computation to allow the reader to
             understand the computational principles involved and to be able to implement
             them in a wide variety of programming languages. In general, special
             MATLAB commands have been avoided, even though their use may have
             made the code more efficient, to reduce the effort that would be required to
             translate the code into a language such as C or C++. One exception,
             however, is the backslash operator, which is described in Chapter 3.
   11   12   13   14   15   16   17   18   19   20   21