ABSTRACT

This chapter addresses functions, scripts, and basic good programming practices. It provides some motivational examples and shows how to run test cases to check reader solutions, making sure they are realistic. The chapter discusses recursive and anonymous functions. The art of programming is the ability to translate from human notation to one that a computer understands. In the spirit of a gradual increase of complexity, we always start with mathematical notation, which serves as the bridge between human language and computer programming language. Essentially, mathematical notation is the universal language from which we can always go to an arbitrary programming language, including Matrix Laboratory (MATLAB). The name of the script file is arbitrary, but it should end with.m to mark this file as executable by MATLAB. The script file by itself is nothing but a simple text file, which can be modified not only by MATLAB's built-in editor but by any text editor as well.