# Fundamentals of Programming

An overview of programming concepts including arrays, strings, loops, and algorithms with a project.
843.0 次下载

# Fundamentals of Programming

or

Curriculum Module

Created with R2023b. Compatible with R2023b and later releases.

# Information

This curriculum module contains interactive MATLAB® live scripts that teach fundamental concepts and basic terminology related to programming computers. This includes discussion of inputs and outputs, numbers, strings, arrays, branches and loops. This content is broken into six instructional live scripts and one project where live script instructions are paired with a plain code practice script. Solutions are available to instuctors upon request.

## Background

You can use these live scripts as demonstrations in lectures, class activities, or interactive assignments outside class. Fundamentals of Programming includes an introduction to programming which includes discussion of errors, documentation, and other commonly encountered challenges for beginners. Data introduces double and string data types. Arrays introduces 1, 2, and 3-D arrays, as well as a brief overview of matrix operations. Applications include both text and image data. Branches introduces the concept of conditional branching in the form of if/else branches and switch statements. Loops introduces the concept of conditional looping in the form of for loops and while loops. Chaos Game Project provides a scaffolded approach to implementing the chaos game by combining skills from each of the other scripts. The final script, Algorithms, introduces algorithms, pseudocode, and testing. Additional files include the navigation file Main Menu and the Collected Pro Tips.

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, when an animation is in progress), use the Stop button in the RUN section of the Live Editor tab in the MATLAB Toolstrip.

Solutions are available upon instructor request. Contact the MathWorks teaching resources team if you would like to request solutions, provide feedback, or if you have a question.

## Prerequisites

This module assumes familiarity with basic mathematics at a high school level. One exercise in Data.mlx requires the use of the quadratic formula, for instance. Understanding the chaos game requires locating points on a Cartesian coordinate system and understanding of either vectors or midpoints. Trigonometric functions are used as example functions. With respect to programming knowledge, this module is intended for absolute beginners who have used simple calculators in the past.

## Getting Started

### On Desktop:

Download or clone this repository. Open MATLAB, navigate to the folder containing these scripts and double-click on FundamentalsofProgramming.prj. It will add the appropriate files to your MATLAB path and open an app that asks you where you would like to start.

Ensure 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 Add-Ons > Get Add-Ons.

## Products

MATLAB® is used throughout. The imsplit command in Arrays.mlx is from the Image Processing Toolbox™.

# Scripts

## Introduction.mlx

Introduction In this script, students will...
- recognize and use the terms input and output.
- recognize, interpret, and respond to messages about syntax errors.
- recognize and interpret comments in code.
- recognize and explain the importance of attention to detail when coding.

## Data.mlx

Data In this script, students will...
- recognize and explain that floating point arithmetic does not operate under the same rules as real number arithmetic.
- apply the limitations of floating point arithmetic to computation.
- recognize and use strings to store and communicate textual data.
- recognize and use whitespace in string operations.
- recognize and interpret special characters that are neither text nor numbers.
- recognize and explain simple consequences of the interactions between data types.

## Arrays.mlx

Arrays In this script, students will...
- identify, create, and use vectors and matrices containing numbers or text.
- use vector indexing to extract information from a vector or matrix.
- identify standard file types and the corresponding extensions.
- explain why file type matters and import data from external files.
- recognize and use three dimensional arrays.

## Branches.mlx

Branches In this script, students will...
- recognize and apply if/then branching logic to solve problems.
- recognize and apply switch branching logic to solve problems.

## Loops.mlx

Loops In this script, students will...
- use for loop logic and syntax to write and execute iterative code.
- use while loop logic and syntax to write and execute repetitive code, and decide when it is the correct method.

## Chaos Game Project

Project In this script, students will...
- apply conditional branching and looping logic in context to solve problems.
- explain that different programming solutions to the same problem can run in very different amounts of time.
- identify common file formats and their extensions.
- communicate results by exporting data from a program in a standard, shareable file format.

## Algorithms.mlx

Algorithms In this script, students will...
- explain the concept of an algorithm.
- implement an algorithm presented in pseudocode.
- explain the importance of testing both code and algorithms.

Collected Pro Tips - Notes on how to implement particular concepts in MATLAB

# Related Courseware Modules

Courseware Module Sample Content Available on:
Treasure Hunt Game: Learn to Code
Build and customize an interactive searching game
GitHub
Programming: Structuring Code
Learn how to organize your code into functions, debug, comment, and share
GitHub
Programming: Organizing Data
GitHub

Programming: A Starter Project Using MATLAB and Python
Use MATLAB, Python, and the OpenWeather API together to implement a weather prediction dashboard

GitHub

Or feel free to explore our other modular courseware content.

# How to Contribute

Looking for more? Find an issue? Have a suggestion? Please contact the MathWorks teaching resources team. If you want to contribute directly to this project, you can find information about how to do so in the CONTRIBUTING.md page on GitHub.

### 引用格式

Emma Smith Zbarsky (2024). Fundamentals of Programming (https://github.com/MathWorks-Teaching-Resources/Fundamentals-of-Programming/releases/tag/v1.1.0), GitHub. 检索来源 .

##### 平台兼容性
Windows macOS Linux
##### 社区
Distance Learning 社区中有更多文件

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

#### Utilities/OldVersions

1.1.0.0

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Fundamentals-of-Programming/releases/tag/v1.1.0

1.0.6.0

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Fundamentals-of-Programming/releases/tag/v1.0.6

1.0.5

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Fundamentals-of-Programming/releases/tag/v1.0.5

1.0.4

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Fundamentals-of-Programming/releases/tag/v1.0.4

1.0.3

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Fundamentals-of-Programming/releases/tag/v1.0.3

1.0.2

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Fundamentals-of-Programming/releases/tag/v1.0.2

1.0.1

See release notes for this release on GitHub: https://github.com/MathWorks-Teaching-Resources/Fundamentals-of-Programming/releases/tag/v1.0.1

1.0.0