% solve for V for a capacitor, with period boundary conditions % mesh size M = 7; N = 7; % initialize V0 = zeros(M,N); %V0 = ones(M,N)*7; % bondary conditions V0(:,1) = -1; V0(:,end) = 1; V1 = V0; % exit tolerance & take one step tol = 1e-5; n = 1 V1 = laplaceStepJacobiPBC(V1,V0) while sum(sum(abs(V1(2:end-1,1:end-1)-V0(2:end-1,1:end-1)))) ... / ... (M*(N-2)) > tol %for k = 1:1005 V0 = V1; n = n+1 V1 = laplaceStepJacobiPBC(V1,V0) end return