This warning means that when you are calculating a vector or matrix element-by-element in a loop, MATLAB performs faster if the vector or matrix is initialized first, meaning that an amount of memory is allocated for the whole vector or matrix variable rather than memory for a single element having to be allocated each time the loop iterates. Obviously you can only preallocate if you know what size the vector or matrix will be before the loop starts, which luckily is the case in this case.
So when you initialize the variable pest, instead of setting it to be empty, you can set it to have 1001 elements (the number of iterations of the timeval loop). It doesn't matter what the value of pest is before the loop because each element will be overwritten by the loop, so it is customary to initialize with zeros:
pest = zeros(1,100/interval+1);
Best Answer