Integrate PDEPE solution wrt x
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jayant Choudhary
el 17 de Jun. de 2020
Comentada: Jayant Choudhary
el 19 de Jun. de 2020
I have solved a 1D spherical Diffusion PDE using pdepe in Matlab, which has given me Concentration(x,t) {= } as a 2D array Now in continuation of my research, I need to find Stress as a function of distance and time {= }, whose expression has terms of and . How should I tackle this part, ie, integrate x^2.C(x,t) wrt x.
0 comentarios
Respuesta aceptada
Bjorn Gustavsson
el 17 de Jun. de 2020
This rather straightforward method should get the job done (assuming you cannot get away with simply use trapz, or cumtrapz, but will definitely need the integral at "all" points in x and y and not only the ones you got out of the PDE-solution of C):
C = peaks(123); % Just making up some mock-up data
x = 0:122; % and X
t = 0:122; % and t-coordinates
[X,T] = meshgrid(x,t);
I1 = @(t,a,b) integral(@(x) interp2(X,T,P,x,t),a,b)
% this gives you a function to evaluate for any time and point along x,
% below for time 12 s integration boundaries from 3 to 37
I1(12,3,37)
HTH
3 comentarios
Bjorn Gustavsson
el 19 de Jun. de 2020
Ok, if you're a recent matlaber, then I guess the anonymous functions are one of the most tricky parts to wrap your head around. Take some time to really grasp that construct.
In this case you don't integrate a matrix, in my solution you integrate a function where the function calculates the function-values by interpolation of the C matrix for an arbitrary point in time and along all values of x that the integral-function asks for. That way you should be able to modify the function I used to something like:
@(x) x.^2.*interp2(X,T,P,x,t)
Instead of what I used.
Más respuestas (0)
Ver también
Categorías
Más información sobre General PDEs 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!