function [M] = solve_direct(M) % We solve the system directly for a grid of 5*5 where there are 4 % equations for points of F and one equation for a point of G. % The boundaries are fixed and moreover they are zero since by now we are % dealing just with the error (zero boundary) % % In total we get 4 dependent equations for F and adding the G equation we % get a fully determined system with 5 equations. s = size(M); rows = s(1); cols = s(2); h = .25; if (rows ~= 5) 'Error: can not solve directly.' else % We solve the equations here directly %======================= % The F,G points a = M(2,2) ; b = M(2,4) ; c = M(4,2) ; d = M(4,4) ; e = M(3,3) ; if (abs(a+b+c+d) > exp(-5)) 'Error[In solve_direct.m]: abs(a+b+c+d) > exp(-5)' end % The expanded equations % ======================= M(3,2) = 2*(a/2 + b/4 - c/4 + e/4); M(3,4) = 2*(a/2 + b*.75 + c/4 - e/4); M(2,3) = 2*(a/2 - b/4 + c/4 - e/4); M(4,3) = 2*(a/2 + b/4 + c*.75 + e/4); end % [M(3,2),M(3,4),M(2,3),m(4,3)] = solve('M(3,2) + M(2,3) = M(2,2)*2*h', 'M(3,4) - M(2,3) = M(2,4)*2*h', '-M(3,2)+ M(4,3) = M(4,2)*2*h', '-M(3,4)- M(4,3) = M(4,4)*2*h', 'M(4,3) - M(2,3) -M(3,4) + M(3,2) = M(3,3)*2*h'); % M_2_2 = M(2,2) ; M_2_4 = M(2,4) ; M_4_2 = M(4,2) ; M_4_4 = M(4,4) ; M_3_3 = M(3,3); % solve('M_3_2 + M_2_3 = M_2_2*2*h', 'M_3_4 - M_2_3 = M_2_4*2*h', '-M_3_2+ M_4_3 = M_4_2*2*h', '-M_3_4- M_4_3 = M_4_4*2*h', 'M_4_3 - M_2_3 -M_3_4 + M_3_2 = M_3_3*2*h','M_3_2,M_3_4,M_2_3,M_4_3' )