Programming: Structuring Code

您所在的位置:网站首页 sharingcode Programming: Structuring Code

Programming: Structuring Code

2023-02-20 05:56| 来源: 网络整理| 查看: 265

Programming: Structuring Code

View Programming: Organizing Data on File Exchange or Open in MATLAB Online

Curriculum Module Created with R2021b. Compatible with R2021b and later releases.

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, describing, debugging, and sharing code.

These scripts can be used as part of a lecture, as activities in an instructional setting, or as interactive assignments to be completed outside class.

##Get started with the Programming: Structuring Code interactive examples## by downloading and unzipping the repository. Then, double-click the StructuringCode.prj file inside MATLAB®. From there, you can follow the landing page instructions to get started with the examples. The 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, if a loop is running longer than intended), click the Stop button in the RUN section of the Live Editor tab in the MATLAB Toolstrip.

Prerequisite Domain Knowledge

This 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 Fundamentals of Programming.

Details

Functions.mlx Open in MATLAB Online

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.

Learning Goals: In this script, students will...

use mathematical functions to use MATLAB as a calculator. use the documentation to locate functions and determine how to use them. write simple functions with inputs, outputs, and side effects, and ensure the functions are on your MATLAB path. pass functions as arguments by using function handles.

Debugging.mlx Open in MATLAB Online

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.

Learning Goals: In this script, students will

identify warning messages and locate and fix the problem. locate and fix syntax errors. recognize and isolate run-time errors.

CommentingCode.mlx Open in MATLAB Online

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.

Learning Goals: In this script, students will...

write comments and documentation for a self-defined function. select meaningful variable names and add code and documentation to an existing function.

SharingCode.mlx Open in MATLAB Online

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.

Learning Goals: In this script, students will...

add scripts to a project. clone a GitHub repository. use the Compare tool to see differences between two versions of the same live script. Related Courseware Modules Fundamentals of Programming on GitHub or View File Exchange Title on File Exchange Programming: Organizing Data on GitHub or View File Exchange Title on File Exchange Products

MATLAB®

License

The license for this module is available in the License.md file in this GitHub repository.

Support

Have any questions or feedback? Contact the MathWorks online teaching team.

Copyright 2022 The MathWorks, Inc.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3