Nonlinear Finite Difference Method

The Finite Difference Method is employed for solving a nonlinear boundary value problem.
3.7K 次下载
更新时间 2010/1/12

查看许可证

The function nonlinearBVP_FDM .m is an implementation of the
nonlinear finite difference method for the general nonlinear
boundary-value problem ---------------------------------------------
y''=f(x,y,y'), for a<x<b where y(a)=alpha and y(b)=beta.
----------------------------------------------------------------------------
The interval [a,b] is divided into (N+1) equal subintervals
with endpoints at x(i)=a+i*h for i=0,1,2,...,N+1.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Remarks:
The function f should be defined as an m-file.
There is NO need for partial derivatives of f
See given example
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Example
Solve the nonlinear boundary value problem
y''=(1/8)*(32+2x^3-yy'), for 1<x<3, where y(1)=17 and y(3)=43/3
Step 1...
Create the function f as a separate m-file and save it in the
current working directory.
function f = f(x,y,yp)
f = (1/8)*(32+2*x^3-y*yp); %Note that yp=y'
Step 2...
In the command window type
>> Y = nonlinearBVP_FDM(1,3,17,43/3);
Note that Y(:,1) represents x and Y(:,2) is vector y(x)
The solution is then plotted in a new figure
If the exact solution is given, plot it for comparison
>> yexact = (Y(:,1)).^2+16./Y(:,1); plot(Y(:,1),yexact,'c')

引用格式

Ernesto Momox Beristain (2024). Nonlinear Finite Difference Method (https://www.mathworks.com/matlabcentral/fileexchange/26358-nonlinear-finite-difference-method), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2008b
兼容任何版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0