Programming Basics

Procedures, control flow, interactive input

MuPAD® support standard programming structures, such as if-then-else statements and for-, while-, and repeat-loops.

When you have a sequence of commands to perform repeatedly or that you want to save for future reference, store them in a program file. A MuPAD program file is a text file that contains any code snippet that you want to store separately from other computations. Saving a code snippet as a program file can be very helpful when you want to use the code in several notebooks. Typically, a program file contains a single procedure, but it also can contain one or more procedures or functions, assignments, statements, tests, or any other valid MuPAD code.

As a shortcut for simple procedures, create and use functions. Compared to procedures, functions require less complicated syntax. Like procedures, functions let you use the same code for different arguments as many times as you need.

Was this topic helpful?