Effacer les filtres
Effacer les filtres

Integration using Green's function in MatLab

14 vues (au cours des 30 derniers jours)
pritha
pritha le 11 Juin 2023
Commenté : pritha le 12 Juin 2023
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?

Réponse acceptée

Shubh Pareek
Shubh Pareek le 12 Juin 2023
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 commentaires
Torsten
Torsten le 12 Juin 2023
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 le 12 Juin 2023
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by