Reputation: 11
Basically I have a loop that goes from i=1:1000. I have something like this.
for i=1:1000
y(i) = rho*y(i-1) + u(i);
u here is drawing from a normal with mean 0 and var. 1. I have to set the value of y(0)=0. That is in the loop when i=1, the rho*y(0) part has to equal zero and so the value that the process would take when i=1 will just be u(i). How can I set y(0)=0?
Thanks
Upvotes: 0
Views: 498
Reputation: 1603
You can do the following - set the first element of y to be the first element of u then iterate starting at i=2
y(1) = u(1);
for i=2:1000
y(i) = rho*y(i-1) + u(i);
end
Upvotes: 1