Include Page |
---|
| SIMULATION: MATLAB Google AnalyticsSIMULATION: |
---|
| MATLAB Google Analytics |
---|
|
Include Page |
---|
| Spring-Mass System - Panel |
---|
| Spring-Mass System - Panel |
---|
|
Step 2: Array Pre-Allocation
The Need for Array Pre-Allocation
The MATLAB code analyzer produces two warnings about our x and t arrays changing size on every iteration as demonstrated in the video below. These warnings can be addressed by pre-allocating the memory for these arrays.
...
HTML |
---|
<iframe width="600" height="450" src="//www.youtube.com/embed/iSVEN_feRKA?rel=0" frameborder="0" allowfullscreen></iframe> |
Pre-Allocation Procedure
We pre-allocate the x and t arrays using the zeros function as shown below.
HTML |
---|
<iframe width="600" height="338" src="//www.youtube.com/embed/BFR8WjtYwNg?rel=0" frameborder="0" allowfullscreen></iframe> |
Change in Run-Time due to Pre-Allocation
We next use the "profiler" in MATLAB to check how much the run-time decreases due to pre-allocation.
...