"Roger Stafford" wrote in message <k59u2b$e4c$1@newscl01ah.mathworks.com>...
> "Konst " <konstance1@hotmail.com> wrote in message <k59cbj$2le$1@newscl01ah.mathworks.com>...
> > The first loop runs OK. But then when t becomes 11 it says that in line alpha(1:n,j)=y(i+1:i+n,1); index exceeds matrix dimensions. .....
>          
> I don't see any error at t = 11, but at t = 12 you will have kapa = 42 and, because 12*42 = 504, at the last trip through the forlop you will call on y(493:504) which is out of range. You had better change from round(kapa) to floor(kapa).
>
> Roger Stafford
But isn't the while supposed to control that I am below 500?
I changed to floor but it still gives me the same mistake at t=11. Then I did this:
for j=1:kapa
if (i+n)<N
alpha(1:n,j)=y(i+1:i+n,1);
alphadetrend(1:n,j)=detrend(alpha(1:n,j));
i=i+n;
end
end
i=1;
for j=1:kapa
for k=1:n
if i<=N
Y(i,1)=alphadetrend(k,j);
i=i+1;
end
end
end
which I think does exactly the same but I was aimin to have better control over the indexes. Still the same error though.
