Problem is in this line:
u(i, j, 2, z(zindex), n(nindex))= G(z(zindex), n(nindex))/ro(z(zindex), n(nindex))^2*dt^2*((1/deltar^2)*(u(i+1,j,1)-2*u(i,j,1)+u(i-1,j,1))...
+(1/(ri*2*deltar))*(u(i+1,j,1)-u(i-1,j,1))+(1/deltaz^2)*(u(i,j+1,1)-2*u(i,j,1)+u(i,j-1,1))-(1/ri^2)*(u(i,j,1))) + 2*u(i,j,1) - u(i,j,1);
RHS works fine for the first step....but the LHS is a problem......check the value of n(nindex) which is the index for LHS..its value is 0.1.....you cannot use fractions, zero and negative numbers as the indices.....you need to think what exactly you want..and what you are trying to achieve.
Learn about debugging the code..it is the good and best practice to get your mistakes and correct them.
Best Answer