% Assemble the global stiffness matrix K = zeros(nx+1, nx+1); for i = 1:nx K(i:i+1, i:i+1) = K(i:i+1, i:i+1) + Ke; end
% Run the solver u = poisson1d(f, nx);
% Apply boundary conditions K(1,:) = 0; K(1,1) = 1; K((nx+1)*(ny+1),:) = 0; K((nx+1)*(ny+1), (nx+1)*(ny+1)) = 1;
% Define the element stiffness matrix k = 1/(nx+1); % element size Ke = [1 -1; -1 1]/k;