%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% poisson_sor.m %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% x_left = 0.0; x_right = 1.0; y_bottom = 0.0; y_top = 1.0; J = 12; K = 12; n = 0; N = 100; dx = (x_right - x_left)/J; dy = (y_top - y_bottom)/K; omega = 2.0/(1.0 + sin(pi/(J+1))); d = (J+1)*(K+1); x = linspace(x_left,x_right,J+1); y = linspace(y_bottom,y_top,K+1); u = zeros(d); b = zeros(d); u_matrix = zeros(J+1,K+1); B = zeros(J+1,K+1); u_matrix = boundary_conditions(x,y); for j = 1:J+1 for k = 1:K+1 B(j,k) = dx*dx*(x(j)^2 + y(k)^2.0); end end for k = 1:K+1 for j = 1:J+1; l = ; u(l) = u_matrix(j,k); end end for l = 1:d column = ; row = ; if column ~= 1 && column ~= K+1 if row ~= 1 && row ~= J+1 u(l) = .5; end end b(l) = B(row,column); end for n = 1:N for l = 1:d column = ; row = ; if column > 1 && column < K+1 if row > 1 && row < J+1 index1 = ; index2 = ; index3 = ; index4 = ; u(l) = end end end end for l = 1:d column = ; row = ; u_matrix(row,column) = u(l); end surf(x,y,u_matrix')