{"id":21478391,"url":"https://github.com/mathworks-teaching-resources/programming-structuring-code","last_synced_at":"2025-07-15T11:30:52.534Z","repository":{"id":53395876,"uuid":"521386976","full_name":"MathWorks-Teaching-Resources/Programming-Structuring-Code","owner":"MathWorks-Teaching-Resources","description":"This curriculum module contains interactive live scripts that teach fundamental concepts and basic terminology related to programming computers. This module focuses on organizing code into functions, and describing, debugging, and sharing code.","archived":false,"fork":false,"pushed_at":"2024-08-23T21:13:09.000Z","size":13330,"stargazers_count":11,"open_issues_count":1,"forks_count":5,"subscribers_count":4,"default_branch":"release","last_synced_at":"2024-08-23T22:28:22.639Z","etag":null,"topics":["commenting","debugging","functions","matlab","matlab-live-script","programming","sharing-code"],"latest_commit_sha":null,"homepage":null,"language":"MATLAB","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MathWorks-Teaching-Resources.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-04T19:12:57.000Z","updated_at":"2024-08-23T22:28:25.794Z","dependencies_parsed_at":"2024-08-23T22:28:25.198Z","dependency_job_id":"40340788-28f4-45bc-afec-1ec54b2d032d","html_url":"https://github.com/MathWorks-Teaching-Resources/Programming-Structuring-Code","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathWorks-Teaching-Resources%2FProgramming-Structuring-Code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathWorks-Teaching-Resources%2FProgramming-Structuring-Code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathWorks-Teaching-Resources%2FProgramming-Structuring-Code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathWorks-Teaching-Resources%2FProgramming-Structuring-Code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MathWorks-Teaching-Resources","download_url":"https://codeload.github.com/MathWorks-Teaching-Resources/Programming-Structuring-Code/tar.gz/refs/heads/release","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226033480,"owners_count":17563169,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["commenting","debugging","functions","matlab","matlab-live-script","programming","sharing-code"],"created_at":"2024-11-23T11:18:00.687Z","updated_at":"2024-11-23T11:18:01.428Z","avatar_url":"https://github.com/MathWorks-Teaching-Resources.png","language":"MATLAB","readme":"\n# \u003cspan style=\"color:rgb(213,80,0)\"\u003eProgramming: Structuring Code\u003c/span\u003e\n\n\n[![View on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/115905-programming-structuring-code) or [![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Programming-Structuring-Code\u0026project=StructuringCode.prj\u0026file=README.mlx)\n\n[![MATLAB Versions Tested](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FMathWorks-Teaching-Resources%2FProgramming-Structuring-Code%2Frelease%2FImages%2FTestedWith.json)](https://MathWorks-Teaching-Resources.github.io/Programming-Structuring-Code)\n\n**Curriculum Module**\n\n_Created with R2024a. Compatible with R2024a and later releases._\n\n# Information\n\nThis curriculum module contains interactive [MATLAB® live scripts](https://www.mathworks.com/products/matlab/live-editor.html) that  teach fundamental concepts and basic terminology related to programming computers. This module focuses on organizing code into functions, describing, debugging, and sharing code.\n\n\n## Background\n\nYou can use these live scripts as demonstrations in lectures, class activities, or interactive assignments outside class. This module covers using built\\-in and user\\-defined functions, commenting code and choosing variable names, utilizing warning messages and run\\-time errors to locate and fix bugs, comparing different versions of a script, cloning a GitHub repository, and creating a MATLAB project. \n\n\nThe instructions inside the live scripts will guide you through the exercises and activities. Get started with each live script by running it one section at a time. To stop running the script or a section midway (for example, when an animation is in progress), use the \u003cimg src=\"Images/EndIcon.png\" width=\"19\" alt=\"EndIcon.png\"\u003e Stop button in the **RUN** section of the **Live Editor** tab in the MATLAB Toolstrip.\n\n## Contact Us\n\nSolutions are available upon instructor request. Contact the [MathWorks teaching resources team](mailto:onlineteaching@mathworks.com) if you would like to request solutions, provide feedback, or if you have a question.\n\n\n## Prerequisites\n\nThis module assumes familiarity with basic programming concepts such as floating point doubles and strings, structures including constants, vectors, matrices, and arrays, and control flows including if/else, for loops, and while loops, as well as how to use them in MATLAB. These ideas are all presented with interactive examples in [\u003cu\u003eFundamentals of Programming\u003c/u\u003e](https://www.mathworks.com/matlabcentral/fileexchange/103225-fundamentals-of-programming).\n\n\n## Getting Started\n### Accessing the Module\n### **On MATLAB Online:**\n\nUse the [\u003cimg src=\"Images/OpenInMO.png\" width=\"136\" alt=\"OpenInMO.png\"\u003e](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Programming-Structuring-Code\u0026project=StructuringCode.prj) link to download the module. You will be prompted to log in or create a MathWorks account. The project will be loaded, and you will see an app with several navigation options to get you started.\n\n### **On Desktop:**\n\nDownload or clone this repository. Open MATLAB, navigate to the folder containing these scripts and double\\-click on [StructuringCode.prj](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Programming-Structuring-Code\u0026project=StructuringCode.prj\u0026file=README.mlx). It will add the appropriate files to your MATLAB path and open an app that asks you where you would like to start. \n\n\nEnsure you have all the required products (listed below) installed. If you need to include a product, add it using the Add\\-On Explorer. To install an add\\-on, go to the **Home** tab and select  \u003cimg src=\"Images/AddOnsIcon.png\" width=\"16\" alt=\"AddOnsIcon.png\"\u003e **Add-Ons** \u003e **Get Add-Ons**. \n\n## Products\n\nMATLAB® is used throughout, and the Symbolic Math Toolbox™ is used for the ShowTaylor example in Functions.mlx.\n\n# Scripts\n## [**Functions.mlx**](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Programming-Structuring-Code\u0026project=StructuringCode.prj\u0026file=Scripts/Functions.mlx) \n|      |      |      |\n| :-- | :-- | :-- |\n|  | **In this script, students will...** \u003cbr\u003e  | **Summary** \u003cbr\u003e   |\n| \u003cimg src=\"Images/Refactor.png\" width=\"171\" alt=\"Refactor.png\"\u003e \u003cbr\u003e  | $\\bullet$ use mathematical functions to use MATLAB as a calculator. \u003cbr\u003e $\\bullet$ use the documentation to locate functions and determine how to use them. \u003cbr\u003e $\\bullet$ write simple functions with inputs, outputs, and side effects, and ensure the functions are on your MATLAB path. \u003cbr\u003e $\\bullet$ pass functions as arguments by using function handles. \u003cbr\u003e  | Organizing code into functions improves the readability, reusability, and ease of testing. This script addresses built\\-in functions, refactoring code to create functions, local functions, functions defined in their own files, programmatic scope and the MATLAB path, and how to pass functions as arguments to other functions. \u003cbr\u003e   |\n|      |      |       |\n\n## [**Debugging.mlx**](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Programming-Structuring-Code\u0026project=StructuringCode.prj\u0026file=Scripts/Debugging.mlx) \n|      |      |      |\n| :-- | :-- | :-- |\n|  | **In this script, students will...** \u003cbr\u003e  | **Summary** \u003cbr\u003e   |\n| \u003cimg src=\"Images/StoppedAtBreakpoint.png\" width=\"171\" alt=\"StoppedAtBreakpoint.png\"\u003e \u003cbr\u003e  | $\\bullet$ identify warning messages and locate and fix the problem. \u003cbr\u003e $\\bullet$ locate and fix syntax errors. \u003cbr\u003e $\\bullet$ recognize and isolate run\\-time errors. \u003cbr\u003e  | Everyone makes mistakes when coding or interacting with computer programs, but you can fix these mistakes. This script introduces the MATLAB Code Analyzer, errors, warnings, breakpoints, stepping, and other tools for minimizing errors as well as identifying and removing bugs from your programs. \u003cbr\u003e   |\n|      |      |       |\n\n## [**CommentingCode.mlx**](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Programming-Structuring-Code\u0026project=StructuringCode.prj\u0026file=Scripts/CommentingCode.mlx) \n|      |      |      |\n| :-- | :-- | :-- |\n|  | **In this script, students will...** \u003cbr\u003e  | **Summary** \u003cbr\u003e   |\n| \u003cimg src=\"Images/Comment.png\" width=\"171\" alt=\"Comment.png\"\u003e \u003cbr\u003e  | $\\bullet$ write comments and documentation for a self\\-defined function. \u003cbr\u003e $\\bullet$ select meaningful variable names and add code and documentation to an existing function. \u003cbr\u003e  | Clearly documenting and communicating your thinking is essential to program with others or even your future self. This script addresses why and how you should document and comment your code. \u003cbr\u003e   |\n|      |      |       |\n\n## [**SharingCode.mlx**](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Programming-Structuring-Code\u0026project=StructuringCode.prj\u0026file=Scripts/SharingCode.mlx) \n|      |      |      |\n| :-- | :-- | :-- |\n|  | **In this script, students will...** \u003cbr\u003e  | **Summary** \u003cbr\u003e   |\n| \u003cimg src=\"Images/CodeCompare.png\" width=\"171\" alt=\"CodeCompare.png\"\u003e \u003cbr\u003e  | $\\bullet$ add scripts to a project. \u003cbr\u003e $\\bullet$ clone a GitHub repository. \u003cbr\u003e $\\bullet$ use the Compare tool to see differences between two versions of the same live script  \u003cbr\u003e  | Writing code for yourself is the first step, but when you create something useful or interesting, you also need to know how to share your work with others. This script offers a brief introduction to sharing your code with others. \u003cbr\u003e   |\n|      |      |       |\n\n# License\n\nThe license for this module is available in the [LICENSE.md](https://github.com/MathWorks-Teaching-Resources/Programming-Structuring-Code/blob/release/LICENSE.md).\n\n# Related Courseware Modules\n|      |      |      |\n| :-- | :-- | :-- |\n| **Courseware Module** \u003cbr\u003e  | **Sample Content** \u003cbr\u003e  | **Available on:** \u003cbr\u003e   |\n| [**Programming: Organizing Data**](https://www.mathworks.com/matlabcentral/fileexchange/115900-programming-organizing-data) \u003cbr\u003e Learn more about strings, numeric data types,  \u003cbr\u003e memory, and ways of storing data \u003cbr\u003e  | \u003cimg src=\"Images/image_7.png\" width=\"171\" alt=\"image_7.png\"\u003e \u003cbr\u003e  | [\u003cimg src=\"Images/OpenInFX.png\" width=\"91\" alt=\"OpenInFX.png\"\u003e](https://www.mathworks.com/matlabcentral/fileexchange/115900-programming-organizing-data) \u003cbr\u003e [\u003cimg src=\"Images/OpenInMO.png\" width=\"136\" alt=\"OpenInMO.png\"\u003e](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Programming-Organizing-Data\u0026project=OrganizingData.prj) \u003cbr\u003e [GitHub](https://github.com/MathWorks-Teaching-Resources/Programming-Organizing-Data) \u003cbr\u003e   |\n| [**Programming: A Starter Project Using MATLAB and Python**](https://www.mathworks.com/matlabcentral/fileexchange/116490-programming-a-starter-project-using-matlab-and-python) \u003cbr\u003e Use MATLAB, Python, and the OpenWeather API  \u003cbr\u003e together to implement a weather prediction dashboard \u003cbr\u003e  | \u003cimg src=\"Images/image_10.gif\" width=\"171\" alt=\"image_10.gif\"\u003e \u003cbr\u003e  | [\u003cimg src=\"Images/OpenInFX.png\" width=\"91\" alt=\"OpenInFX.png\"\u003e](https://www.mathworks.com/matlabcentral/fileexchange/116490-programming-a-starter-project-using-matlab-and-python) \u003cbr\u003e [\u003cimg src=\"Images/OpenInMO.png\" width=\"136\" alt=\"OpenInMO.png\"\u003e](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Programming-A-Starter-Project-Using-MATLAB-and-Python\u0026project=MATLABwithPython.prj) \u003cbr\u003e [GitHub](https://github.com/MathWorks-Teaching-Resources/Programming-A-Starter-Project-Using-MATLAB-and-Python) \u003cbr\u003e   |\n|      |      |       |\n\n\n**Introductory content:**\n\n-  [**Fundamentals of Programming**](https://www.mathworks.com/matlabcentral/fileexchange/103225-fundamentals-of-programming) is available on [\u003cimg src=\"Images/OpenInFX.png\" width=\"91\" alt=\"OpenInFX.png\"\u003e](https://www.mathworks.com/matlabcentral/fileexchange/103225-fundamentals-of-programming) or [\u003cimg src=\"Images/OpenInMO.png\" width=\"136\" alt=\"OpenInMO.png\"\u003e](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Fundamentals-of-Programming\u0026project=FundamentalsofProgramming.prj) or [GitHub](https://github.com/MathWorks-Teaching-Resources/Fundamentals-of-Programming) \n-  [**Treasure Hunt Game: Learn to Code**](https://www.mathworks.com/matlabcentral/fileexchange/123265-treasure-hunt) is available on [\u003cimg src=\"Images/OpenInFX.png\" width=\"91\" alt=\"OpenInFX.png\"\u003e](https://www.mathworks.com/matlabcentral/fileexchange/123265-treasure-hunt) or [\u003cimg src=\"Images/OpenInMO.png\" width=\"136\" alt=\"OpenInMO.png\"\u003e](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Treasure-Hunt\u0026project=TreasureHunt.prj) or [GitHub](https://github.com/MathWorks-Teaching-Resources/Treasure-Hunt) \n\nOr feel free to explore our other [modular courseware content](https://www.mathworks.com/matlabcentral/fileexchange/?q=tag%3A%22courseware+module%22\u0026sort=downloads_desc_30d).\n\n# Educator Resources\n-  [Educator Page](https://www.mathworks.com/academia/educators.html) \n\n# Contribute \n\nLooking for more? Find an issue? Have a suggestion? Please contact the [MathWorks teaching resources team](mailto:%20onlineteaching@mathworks.com). If you want to contribute directly to this project, you can find information about how to do so in the [CONTRIBUTING.md](https://github.com/MathWorks-Teaching-Resources/Programming-Structuring-Code/blob/release/CONTRIBUTING.md) page on GitHub.\n\n\n *©* Copyright 2024 The MathWorks™, Inc\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks-teaching-resources%2Fprogramming-structuring-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathworks-teaching-resources%2Fprogramming-structuring-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks-teaching-resources%2Fprogramming-structuring-code/lists"}