Рет қаралды 6,542
When working with loop structures, programmers often encounter a warning that states the size of a variable or array is changing inside of a loop and that they should consider preallocation. In this video, I'll explain what preallocation is, why you should care, and how to preallocate an array before a for loop in MATLAB. If you are unfamiliar with for loops or array indexing, I would recommend checking out my four-part series on for loops prior to watching this video (links below).
Four-Part Series on for Loops:
Part 1 introduces the basic structure of a for loop and demonstrates a loop pass. Link to Part 1: • MATLAB for Engineers -...
Part 2 focuses on updating the value of a scalar variable during each loop pass. Link to Part 2: • MATLAB for Engineers -...
Part 3 introduces working with arrays and array indexing inside of a for loop. Link to Part 3: • MATLAB for Engineers -...
Part 4 introduces combining loops and logic by nesting the conditional statements if, elseif, and else inside of a loop. Link to Part 4: • MATLAB for Engineers -...
The background music in the intro and outro was written and produced by Michael J Calamas for the exclusive use of David Calamas.