The code is quite similar to the code that I submitted for mackey glass series prediction (https://www.mathworks.com/matlabcentral/fileexchange/61017-mackey-glass-time-series-prediction-using-least-mean-square--lms-). The main difference is that in testing phase it utilizes the output generated by the filter itself (feedback) to predict next outcome. In this way you can generate data for N future values.
In this submission, LMS is implemented unconventionally as an IIR filter. In this case the stability of the LMS is not guaranteed.
To see the effect of instability, you can introduce some noise in the training data. for example
Data(:,2)=A*sin(2*pi*f*n*ts)% y(t)=sinusoidal signal
Data(:,2)=A*sin(2*pi*f*n*ts)+0.01*randn(1,3001); % y(t)=sinusoidal signal + noise
This is due to the fact that we are giving predicted output as a feedback to the LMS, that amplify the error in prediction of the next outcome.