In this module, you learn how to structure your scripts, how to document your code, and how to use a good programming style to make your code more readable and understandable.
- Study the Structured Programming MLX file (./docs/StructuredProgramming.mlx)
- Become familiar with good programming style in the Matlab Style book by Richard Johnson.
- Watch a video tutorial (without sound!) that takes an example unstructured script and turns it into a better, more structured script and a function.
- Watch another video tutorial about creating analysis functions that are flexible and result in reusable code.
In this assignment, you will be adding structure to an unstructured script.
Start from the valid_date.m script (in the /code folder of this module)
- Go through the script and apply the Style guidelines from Johnson's style book, or as illustrated in the video tutorial.
- Make sure that the script still works and that Lint gives you the green square in the top-right corner.
- Commit and push the structured version to GitHub so that the instructors can review and comment on your code.
If you want to practice more, do the same for one of your own scripts; first add the unstructured version to the /code folder , commit and push (So that the instructors can see what your starting point was), improve it using the instructions above, and then commit and push again to get comments from the instructors.
While there is no formal assignment, please play around with the inputParser to learn abouts its various options - you will need it in future assignments. For instance, you could add it to the code for the Structure Assignment above.
For additional practice, complete the assignments in the Structured Programming handout (some of these are available on Matlab Grader, in the Scripts, Functions & Flow Control section, where you can get some immediate feedback on your proposed solutions).
If you're not yet too familiar with the different kinds of loops and other flow control, please have a look at the Flow Control MLX file (./docs/FlowControl.mlx) or revisit the flow control sections (Program Flow - I and Program Flow - II in the Matlab Basics module.