Borrar filtros
Borrar filtros

Integration using Green's function in MatLab

18 visualizaciones (últimos 30 días)
pritha
pritha el 11 de Jun. de 2023
Comentada: pritha el 12 de Jun. de 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?

Respuesta aceptada

Shubh Pareek
Shubh Pareek el 12 de Jun. de 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 comentarios
Torsten
Torsten el 12 de Jun. de 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 el 12 de Jun. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by