フィルターのクリア

Integration using Green's function in MatLab

14 ビュー (過去 30 日間)
pritha
pritha 2023 年 6 月 11 日
コメント済み: pritha 2023 年 6 月 12 日
I have an integration
phi(r)= int_0^{inf} (r'^2 * dr' * G(r,r') * S(r'))
where G(r,r') = 1/(2*m*r*r')*(exp(-m*(r-r')) - exp(-m*(r+r'))) and S(r') is a known dataset at each r' and m is also known.
How to deal with this integration to find phi(r). Could you please help me on this?

採用された回答

Shubh Pareek
Shubh Pareek 2023 年 6 月 12 日
From what i have understood you want to integrate phi function from 0 to infinity , may be this code can help
also since I didn't know what your dataset function S is so i specified it to be rprime itself.
m = 1; % Some constant value
r = 0.5; % Value of r to evaluate
% Define the function handles for G and S
G = @(r, rprime) 1./(2.*m.*r.*rprime).* (exp(-m.*(abs(r-rprime))) - exp(-m.*(r+rprime)));
S = @(rprime) rprime;% Define your dataset function here
% Define the integrand function
integrand = @(rprime) (rprime.^2) .* G(r, rprime) .* S(rprime);
% Evaluate the integral using MATLAB's integral function
phi_r = integral(integrand, 0, Inf)
phi_r = 2.0739
If you want to know more about integration with multiple variable or how integral function works here are some resources .
  2 件のコメント
Torsten
Torsten 2023 年 6 月 12 日
I think a function of r for phi is more adequate here:
m = 1; % Some constant value
% Define the function handles for G and S
G = @(r, rprime) 1./(2.*m.*r.*rprime).* (exp(-m.*(abs(r-rprime))) - exp(-m.*(r+rprime)));
S = @(rprime) rprime;% Define your dataset function here
% Define the integrand function
integrand = @(r, rprime) (rprime.^2) .* G(r, rprime) .* S(rprime);
% Evaluate the integral using MATLAB's integral function
phi_r = @(r) integral(@(rprime)integrand(r, rprime), 0, Inf);
phi_r(0.5)
ans = 2.0739
pritha
pritha 2023 年 6 月 12 日
Thanks for your reply @Shubh. I was not taking the abs(r-rprime). That's why I couldn't able to solve it. Thanks for helping me out. Thanks @Torsten for your reply. I am getting the result properly now.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by