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!