How to set a vector as initial condition for PDEs?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to set a vector, Cini, containing a spatially-varying quantity as my intial codition in a pde for all except the first instance of a loop (in this instance, initial condition is uniform for r<=R1). In the current wrong syntax (below), it's tripping the code up. How do I go about correctly implementing this?
function c0 = pdex2ic(r)
if r <= R1
if i==1
c0 = C0;
else
c0 = Cini;
end
else
c0 = 0;
end
end
0 commentaires
Réponse acceptée
Torsten
le 23 Déc 2022
Modifié(e) : Torsten
le 23 Déc 2022
Generate two data vectors R and C0 where R covers the complete spatial interval of integration.
Then
function c0 = pdex2ic(r,R,C0)
c0 = interp1(R,C0,r)
end
Note that you will have to pass pdex2ic as @(r)pdex2ic(r,R,C0) to the integrator.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur PDE Solvers dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!