How to set a vector as initial condition for PDEs?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
island-lad
el 23 de Dic. de 2022
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 comentarios
Respuesta aceptada
Torsten
el 23 de Dic. de 2022
Editada: Torsten
el 23 de Dic. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre PDE Solvers en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!