ODE15s solver

1 回表示 (過去 30 日間)
Sean
Sean 2016 年 8 月 15 日
%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 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by