📄 pde1dd_cranknicolson.m
字号:
function PDE1Dd_CrankNicolson
% 使用Crank-Nicolson有限差分方法求解一维动态传热模型
%
% calling the function U = CrankNicolson(f,c1,c2,a,b,c,n,m) to solve the heat equation:
% du(x,t)/dt = α * d2u(x,t)/dx2 over R={(x,t):0<=x<=a,0<=t<=b}
% with u(x,0)=f(x), for 0<=x<=a, and u(0,t)=c1,u(a,t)=c2,for 0<=t<=b.
% Input - f=u(x,0) as a string 'f'
% - c1=u(0,t) and c2=u(a,t)
% - a and b right end points of [0,a] and [0,b]
% - c the constant in the heat equation
% - n and m number of grid points over [0,a] and [0,b]
% Output - U solution matrix
%
% Author: HUANG Huajiang
% Copyright 2003 UNILAB Research Center,
% East China University of Science and Technology, Shanghai, PRC
% $Revision: 1.0 $ $Date: 2002/04/15 $
c1 = 100;
c2 = 0;
a = 10;
b = 8;
alpha = 2;
n = 6;
m = 8;
U = CrankNicolson(@ic,c1,c2,a,b,alpha,n,m)
% ------------------------------------------------------------------
function f = ic(x)
f = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -