dj - on the first iteration of your inner for loop
j=1;
for t=0:deltat:1400;
for i=1:N;
eta(j,i)=a(i)*cos(2*pi*f(i)*t+e(i));
eta(j,N)=eta(j,N)+eta(j,i);
end
end
since you never pre-size (or pre-allocate memory) to eta then it is a 1x1 scalar when you do the first assignment for eta(j,i). On the next line you try to update and access the 1000th (N) element of this scalar...and since it doesn't exist, the access is probably what is throwing the error. You probably want to pre-size the array before entering the outer for loop
While that should fix the error, is it really what you want to do? Why is j never incremented? The fact that it isn't seems to conflict with your call to plot
In the above, you are assuming that eta is a column array but you are initializing it as if it were a row array. I suspect also that the above call to plot is not really what you want unless you are assuming that eta is an axN matrix and so you are plotting with the first and last columns of eta.
Best Answer