You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

Unable to render {include} The included page could not be found.

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.


The following video briefly explains why array pre-allocation leads to faster code. See this blog-post for more information about pre-allocation.


Pre-Allocation Procedure

We pre-allocate the x and t arrays using the zeros function as shown below.


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.


  • No labels