% Apply boundary conditions K(1,:) = 0; K(1,1) = 1; K(nx+1,:) = 0; K(nx+1, nx+1) = 1;

$$-\nabla^2u = f$$

% Compute the load vector F = zeros(nx+1, 1); for i = 1:nx+1 F(i) = f(i*k); end

% Solve the linear system u = K\F;

For 2D problems, such as the Poisson equation:

获取报价
客服 客服
人工客服
返回顶部