Hello,
The error is in variable indexing, in the second for-loop,
add = add+y(j)
instead of "add = add+y(i)".
Also, you would need to take care of the indexing of variable 'i' when the last 'N' sample values of 'ys' are being calculated.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!