Integrate PDEPE solution wrt x
8 ビュー (過去 30 日間)
古いコメントを表示
Jayant Choudhary
2020 年 6 月 17 日
コメント済み: Jayant Choudhary
2020 年 6 月 19 日
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.
} as a 2D array Now in continuation of my research, I need to find Stress as a function of distance and time {= 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 で Eigenvalue Problems についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!