Integrate PDEPE solution wrt x
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Bjorn Gustavsson
2020-6-17
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 个评论
Bjorn Gustavsson
2020-6-19
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 General PDEs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!