This is not an error, this is a warning whichmlint produce to increase the speed and efficiency of your code. It is better to pre-allocate variable's memory to increase speed. For more details, see here:https://www.mathworks.com/help/matlab/matlab_prog/preallocating-arrays.html. However, this warning should not stop the code from execution. The code should work as expected, although slower then pre-allocation. The actual error which I can see in your code is that the variablel is not defined. You are using it at several places of your code but its value is not assigned anywhere. This will be actually causing an error.