Attempted to access eta(1,1000); index out of bounds because size(eta)=[1,2].
Error in surface (line 30)
eta(j,N)=eta(j,N)+eta(j,i);
Why do i get this error? Can anybody help me to understand?
clcclose allN=1000; %number of regular wave components
d=0.4; %depth
A=0.15; %Hs
B=1.6; %Tp
f(1)=0.1; %starting frequency
ff=10;deltaf=(ff-f(1))/(N-1);f=f(1):deltaf:ff;deltat=0.05; %time interval
t=0:deltat:1400; %time series
duration=length(t);e=2*pi*rand(1,N); %phase angle
for i=1:N; T(i)=1/f(i); %period
L(i)=dispersion(T(i),d); %wavelength
k(i)=2*pi/L(i); n(i)=0.5*(1+((2*k(i)*d)/sinh(2*k(i)*d))); a(i)=(2*deltaf*(0.205*(A^2)*(B^-4)*(f(i)^-5)*exp(-0.75*(B*f(i))^-4)))^0.5;endm=zeros(1,duration);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); endendplot(eta(:,1),eta(:,N))xlabel('Time (sec)')ylabel('Surface Elevation,\eta (m)')
Best Answer