I am trying to create a buffer (not circle buffer) for big arrays like 100x100 with a specified size.
I can't find any good solution on the internet so i am trying do write it by myself. Here is the code:
In this exa,ple I will be using only small arrays 2x2 and buffer size is 3
A = [1 1; 1 1];
B = [2 2; 2 2];
C = [3 3; 3 3];
buffer = [C B A];
D = [4 4; 4 4];
Now i want to push D and pop A to look like [D C B]
buffer = buffer(1:2,3:6); %creating [C B]
buffer = [D buffer] %creating [D C B]
Now the question: What about the A in the memory? Is it still there or it is deleted? If I use about 1000 arrays with size [500x500] with buffer size 3 it would be really bad if I had so much trash in memory. If it is wrong, is there any other way to write such buffer?