Afficher commentaires plus anciens
%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.
Réponses (0)
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!