⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bvp.m

📁 sareli<matlab科学计算>配套程序
💻 M
字号:
function [x,uh]=bvp(a,b,N,delta,gamma,fun,ua,ub)%BVP Solve two-point boundary value problem%   [X,UH]=BVP(A,B,N,DELTA,GAMMA,FUN,UA,UB) solves with the%   centered finite difference method the boundary-value%   problem%       -D(DU/DX)/DX+DELTA*DU/DX+GAMMA*U=FUN  %   on the interval (A,B) with boundary conditions U(A)=UA%   and U(B)=UB.%   FUN can be an inline function.h = (b-a)/(N+1); z = linspace(a,b,N+2); e = ones(N,1);A = spdiags([-e-0.5*h*delta 2*e+gamma*h^2 -e+0.5*h*delta], -1:1, N, N); x = z(2:end-1); f = h^2*feval(f,x); f=f';   f(1) = f(1) + ua;   f(end) = f(end) + ub;uh = A\f; uh=[ua; uh; ub]; x = z;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -