The capabilities of Matlab can be extended through programs written in its own programming language. It provides the standard constructs, such as loops and conditionals; these constructs can be used interactively to reduce the tedium of repetitive tasks, or collected in programs stored in ``m-files'' (nothing more than a text file with extension ``.m''). I will first discuss the programming mechanisms and then explain how to write programs.