Matlab code :
Sol(indx,j) = mf* ((alpha/dx^2)*(Sol(indx+1,j-1)-2*Sol(indx,j-1)+Sol(indx-1,j-1))...
+ (K/dt)*Sol(indx,j-1) +(1/dt^2)*(2*Sol(indx,j-1) - Sol(indx,j-2)));
The code I translate :
Sol[indx,j] = mf* ((alpha/(dx**2))*(Sol[indx+1,j-1]-2*Sol[indx,j-1]+Sol[indx-1,j-1])+ (K/dt)*Sol[indx,j-1] +(1/(dt**2))*(2*Sol[indx,j-1] - Sol[indx,j-2]))
I do not think I translate it correctly because the result does not match
Could someone help me? Thanks
edit: I really want to give some test value, but the matrix is about 200*200. I do not think copying/pastng those values is a good idea. And I cannot give you guys the full code because it is an homework question.
dt, because then you'll run into integer division problems (e.g. 1 / 4 = 0). To avoid this, replace your 1/ with 1., or, better, just ensure dt is a float; e.g.dt = float(dt)jorindxever0? Because if they are they will do the completely wrong thing here. How areindxandjchosen? Are you using a loop or are they specified some other way? If a loop, how are the loop terms chosen?