Chapter 5
Vectorized Code
Contents
5.1 Loops with Vectors and Matrices
5.2 Operations on Vectors and Matrices
5.3 Vectors and Matrices as Function Arguments
5.4 Logical Vectors
5.5 Vectorizing Code
5.6 Timing
Key Terms
vectorizing
scalar operations
array operations
logical vectors
logical indexing
Although loops are extremely useful in most programming applications and necessary in many languages, in the MATLAB® software they are frequently not necessary especially when dealing with vectors or matrices. In this chapter, the concept of vectorizing will be introduced, which is the term used in MATLAB for rewriting code that was written using constructs such as loops in a traditional programming language and instead taking advantage of array ...
Get Matlab: A Practical Introduction to Programming and Problem Solving, 2nd Edition 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.