O'Reilly logo

MATLAB For Dummies by John Paul Mueller, Jim Sizemore

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10

Adding Structure to Your Scripts

In This Chapter

arrow Adding decision-making to your scripts

arrow Using recursive functions

arrow Repeating tasks

arrow Defining menus

The scripts and functions you have created so far have all performed a series of tasks, in order, one at a time. However, sometimes it’s important to skip steps or to perform the same step more than once. Humans make decisions about what to do and how often to do it with ease, but computers need a little help. You must provide specific instructions as to when a decision is required and when to do something more than once.

As part of discovering how decisions are made and just how repetition works, you see two practical examples of how to employ your new skills. The first is a technique called recursion, which is simply a method of performing a task more than once, but in an elegant way. Using recursion makes solving some math problems significantly easier. The second involves the use of a menu. Most multifunction applications rely on menus to allow a user to select one option out of a number of possibilities.

Making Decisions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required