6.4: Incremental Development

Matlab and Octave Programming for STEM Applications · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    From LibreTexts, under CC BY-NC-SA 4.0, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    6.4: Incremental Development

    Now that we have relational operators and if statements, let’s start writing the program.

    Here are the steps we will follow to develop the program incrementally:

    1. Write a script named findtriples.m and start with a loop that enumerates values of a and displays them.
    2. Write a second loop that enumerates values of b and a third loop that enumerates values of c.
    3. Use the if statement from the previous section to check whether a, b, and c form a Pythagorean triple.
    4. Display the values that pass the test.
    5. Transform the script into a function and make it take an input variable that specifies the range to search.

    Along the way, we’ll optimize the program to eliminate unnecessary work.


    This page titled 6.4: Incremental Development was last modified on Wed, 13 Jul 2022 23:52:01 GMT and is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Allen B. Downey (Green Tea Press) via source content that was edited to the style and standards of the LibreTexts platform.