Introduction
Suppose I want to initialize a one-dimensional, length-N
array of real numbers in MATLAB, where N
is large enough for this question to matter. I will later overwrite the values, so I am mainly concerned with declaration.
I could do this in two ways:
Case A
arrayA = zeros(1,N);
Case B
arrayB = zeros(N,1);
Question
What are the performance considerations for using either of the above approaches?
- Does one approach initialize faster than the other?
- Does one approach use less memory (even negligibly) than the other?
- Does one approach allow faster memory read/writes?
- Other considerations??
For the purposes of this question, we will assume that the array is "large enough to for anything that could matter to matter", and that there could be many such arrays in a given program.