MATLAB: How to delete previous values recorded

loopprojectile motionrecorded valuestrajectory

hello, it would be of great help if anybody could tell me how to delete previous values recorded by matlab once my loop has reached the value that i needed it to, therefore having a new set of values, because my program is just recording all the values, inclusive the non-desired values and then plotting them, this way reducing accuracy in the graph visual because it is must larger and over a large space of time. thanks in advance luis

Best Answer

It is not perfectly clear to me what you mean. You might want to show us some code. However, here is a guess at what you want:
Suppose you have a vector A of length 102, and you only want to keep the first 100 elements. Each of the following methods would work:
A = A(1:100);
or
A(101:102) = [];
or
A(end-1:end) = [];