ODE15s solver
1 次查看(过去 30 天)
显示 更早的评论
%ODE15s function function F = oden(t,ys) % F is same as dudt, U = ys(1:N,1);
% Boundary
U(1)=0;
U(N)=1;
F(1,1)=beta*((U(2)-2*U(1))/dx/dx)+alpha*(U(2)/(2*dx));
F(2:N-1,1) = beta*((U(3:N)-2*U(2:N-1)+U(1:N-2))/dx/dx)+alpha*((U(3:N)-U(1:N-2))/(2*dx));
F(N,1)=beta*((1-2*U(N)+U(N-1))/dx/dx)+alpha*((1-U(N-1))/(2*dx));
end
end
This is my ODE15s solver for a finite difference for diffusion and convection, could someone tell what is wrong with this formula, because I keep not getting what I hoped for, which is a striaght line. The ghost point for 0 and N+1 is the same as 1 and N. Thank you.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!