資源簡介
泊松方程MATLAB程序
代碼片段和文件信息
????function?U?=?Poisson(fgntolmax_it)
????%?
????%?function?U?=?Poisson(fgntolmax_it)
????%
????%?The?five?point?scheme?for?solving?the?Dirichlet?BVP?of?the
????%?Poisson?equation?on?the?unit?square.
????%?Input
????%??????f:?the?right?hand?side?function
????%??????g:?the?Dirichlet?boundary?value?function
????%??????n:?the?number?of?sub-intervals?of?[01]
????%??????tol:?relative?error?tolerance?of?the?iterative?solution;
????%???????????default?value:?10^(-5)
????%??????max_it:?maximal?number?of?iterations?allowed;
????%???????????default?value:?10000
????%?Output
????%???????U:?the?solution?u_{ij}?ij=1...n+1
????%
????%?To?use?the?program?the?user?must?supply?two?m-files?say
????%?‘f.m‘?and?‘g.m‘?to?define?the?right?hand?side?function?f?of
????%?the?differential?equation?and?the?boundary?value?function?g.
????%?The?user?should?also?choose?a?positive?integer?n?for?the?
????%?number?of?subintervals?of?[01].
????%?A?sample?call?would?be
????%??????U?=?Poisson(‘f‘‘g‘n1e-81000)
????%?with?10^(-8)?as?the?tolerance?for?the?relative?errors?of?the?
????%?iterative?solution?and?a?maximal?number?of?1000?iterations?
????%?is?allowed?for?solving?the?finite?difference?system.
????%?It?is?also?possible?to?use
????%?????U?=?Poisson(‘f‘‘g‘n1e-8)
????%?then?the?maximal?number?of?iterations?is?the?default
????%?value?10^4.?If?the?default?values?10^(-5)?and?10^4?are?
????%?to?be?used?for?the?iteration?relative?error?tolerance?and?
????%?maximal
評論
共有 條評論