I often see people try to store the results in a series of vectors with names like alpha1, alpha2, alpha3… This is not a good idea, it is hard to manipulate and refer to these variables. Better is to store each resultant vector as a row in a larger matrix.
Comments are closed.
2 CommentsOldest to Newest
Hi Dough, another nice video tutorial.
The mat array should be preallocated first don’t you agree?
It depends. The point of my videos is to illustrate a concept clearly an concisely. Pre-allocation would be marginally better in a situation like this, but because the matrices are small it would be only a small improvement.
In real code, I would totally pre-allocate if this was a matrix of any real size, but for small ones I might or might not do it. I prefer clarity and brevity most of the time. If speed becomes an issue later, I can easily add that optimization.
Thanks for asking,