5

Matlab Functions

Chapter Outline

Lesson 5.1 Introduction to Functions

Lesson 5.2 Creating Functions

Lesson 5.3 Scope of Matlab Variables in a Function

Answers to Selected Exercises

Lesson 5.1 Introduction to Functions

Objectives

• To learn about functions in Matlab.

• To understand the purpose of a function.

• To learn how to call a function.

Topics

5.1.1 What Is a Function?

5.1.2 The Purpose of a Function

5.1.2.1 Improves Code Readability

5.1.2.2 Improves Code Reusability

5.1.2.3 Modifying Code

5.1.3 Calling a Matlab Function

5.1.1 What Is a Function?

A Matlab function is a collection of commands that does a specific task and must have a unique name. The function accepts one or more Matlab variables as input arguments, operates on ...

Get MATLAB® by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.