Assume we have X = [A, B] where A and B are two vectors (or matrices). Is concatenation operation copies elements in A? If so is it possible to do concatenation without copying elements?
Possible answer to the second. What if I do the following in order to avoid copying elements: X(1:length(A)) = A; X(length(A)+1:length(A)+length(B)) = B; Does 'copy-on-write' work in this context?
Follow-up question: How can I benchmark these two codes with respect to memory usage? Any ideas?
Best Answer