Shivanshu - presumably the error is with
because on the first iteration of the list, i is 1 yet the code tries to access y1(i-1)...hence the error. I think that you need to reconsider your how you are accessing data from these arrays. I was going to suggest starting from 2 (i.e. for i=2:itt) but I suspect that will lead to other issues.