Translator Disclaimer
Chapter 3:
MATLAB Programming of Functions, Vectors, Arrays, and Fourier Transforms

By following the examples presented in this chapter, you will gain some familiarity with MATLAB, learn how to implement a function, compute the discrete Fourier transform, and compare the result with analytic theory. For instructional purposes, most of the examples are one-dimensional (1D) problems, but two dimensions are introduced at the end of the chapter. MATLAB is a mathematics and graphics software application with its own interpreted language that is widely used for simulation and modeling in science and engineering disciplines. It is optimized for vector and matrix operations and, therefore, is a good tool for Fourier optics simulations, which generally involve at least two dimensions. The examples in this chapter and throughout the book use a basic set of MATLAB features, in part to keep the material at a tutorial level but also because the details of the programming steps are more obvious. As you become familiar with the software, you may find more convenient and efficient ways to implement the programming. MATLAB Version 7.1 is used in this book.

3.1 Defining Functions

Open MATLAB. The windows that are commonly displayed include the "Current Directory," "Command Window," and "Command History." These windows are often grouped together as part of the main window that comprises the MATLAB "Desktop" (Fig. 3.1). The Current Directory shows the folder in which your work will be stored and MATLAB-related files that are in that folder. Code can be entered in the Command Window where it is executed a line at a time as it is entered. Numerical output, such as the value of a variable, can also be displayed in the Command Window. The Command History shows a compact listing of the commands that have been entered in the Command Window.

Online access to SPIE eBooks is limited to subscribing institutions.

Back to Top