...
The MATLAB code analyzer produces two warnings about our x and t arrays changing size on every iteration as demonstrated in the video below.
HTML |
---|
<iframe width="600640" height="450480" src="//www.youtube.com/embed/N9JEnT76BKY?rel=0" frameborder="0" allowfullscreen></iframe> |
...
The following video briefly explains the concept of array pre-allocation. See this blog-post for more information about pre-allocation.
HTML |
---|
<iframe width="600640" height="450480" src="//www.youtube.com/embed/iSVEN_feRKA?rel=0" frameborder="0" allowfullscreen></iframe> |
...
We pre-allocate the x and t arrays using the zeros function as shown below.
HTML |
---|
<iframe width="600640" height="450480" src="//www.youtube.com/embed/BFR8WjtYwNg?rel=0" frameborder="0" allowfullscreen></iframe> |
...
We next use the "profiler" in MATLAB to check how much the run-time decreases due to pre-allocation.
HTML |
---|
<iframe width="600640" height="450480" src="//www.youtube.com/embed/bfqQTGe_pxU?rel=0" frameborder="0" allowfullscreen></iframe> |
...