matlab中导数边界条件的有限差分方法

时间:2018-03-14 11:38:21

标签: matlab pde

我试过这个代码来解决带有导数边界条件的有限差分偏微分方程,试图在if语句中输入系统的边界条件,但是当函数是      partial(T)/ partial(t)= partial ^ 2(T)/ partial ^ 2(x)+ 100 * sin(pi * x)

clear all
clc
n=40; %number of division for x 
 j=500;
dx=0.25;
dt=0.025;
x=0:dx:5;
alpha=0.4;
for j=1:dt:500;
     for i=1:dx:n+1;  
         T=ones(i+1,j)
         T(:,0)=0 %intial condition 
         T(n+1,j+1)=T(n+1,j)+(2*dt/dx^2)*(T(n,j)-(T(n+1,j)*
(1+dx))+10*dx)%for the derivative boundary condition at N+1  
         T(2,j+1)=  T(0,j+1)+(2*dx)*(T(1,j+1)-10)    %for the second 
derivative  boundary condition 
     T(i,j+1)=T(i,j)+(dt/dx^2)*(T(i-1,j)-2*T(i,j)+T(i+1,j))+100*sin(pi*x)*dt %the nodal equation
     end
 end

0 个答案:

没有答案