function V1 = laplaceStepJacobiPBC(V1,V0) %V1 = laplaceStepJacobiPBC(V0); % assumes that B.C. specify V on the exterior edges in 2D % handle first row using periodic BC for jj = 2:size(V0,2)-1 V1(1,jj) = ... (V0(2,jj) + V0(end,jj) + V0(1,jj+1) + V0(1,jj-1))/4; end for ii = 2:size(V0,1)-1 for jj = 2:size(V0,2)-1 V1(ii,jj) = ... (V0(ii+1,jj) + V0(ii-1,jj) + V0(ii,jj+1) + V0(ii,jj-1))/4; end end % handle last row using periodic BC for jj = 2:size(V0,2)-1 V1(end,jj) = ... (V0(1,jj) + V0(end-1,jj) + V0(end,jj+1) + V0(end,jj-1))/4; end return