Double integration with Range

18 visualizzazioni (ultimi 30 giorni)
Michael Henry
Michael Henry il 16 Apr 2017
Commentato: Star Strider il 17 Apr 2017
Hello my friends.
I really need your help with my problem. I want to perform double integration with respect to x and y. However, x, which is the internal integration, has a range. Then, I need to plot this result.
Please note that my internal integration should be solved " numerically", I guess, as I can't find closed form solution to the internal integration, g1 in my code. Moreover, my integration are from zero to infinity.
I tried to write the code and I copied what I got so far down and I don't think this leads to the solution.
Please take a look and any suggestions will be really appreciated. Have a wonderful day!
clc
clear all;
syms a b lambda y;
x = 1:100;
for ii = 1:length(x)
%%f1 function integration with respect to x
f1 = @(x) lambda*exp(-a*y)*exp((b*y)/(x(ii)+1)) * exp(-lambda*x(ii));
g1(ii) = integral(f1,0,inf);
%%After finding g1 with respect to x, the desired integration is with respect to y
F(y) = (1./y).*(exp(-y) - exp(-y).*g1(ii));
lambda = sym(2);
a = sym(0.8);
b = sym(0.2);
fsub = subs(F);
Fsym(ii) = integral(fsub, y, 0, inf);
end
%%The plot should be with respect to x
fplot(Fsym, [0 100])

Risposta accettata

Star Strider
Star Strider il 16 Apr 2017
Try this:
syms x y
lambda = sym(2);
a = sym(0.8);
b = sym(0.2);
f1(x,y) = lambda*exp(-a*y).*exp((b*y)./(x+1)) .* exp(-lambda*x);
x = sym(1:100);
inty = double(int(f1(x,y), y, 0, Inf));
figure(1)
semilogy(x, inty)
xlabel('x')
ylabel('Integral with respect to x')
grid
  13 Commenti
Michael Henry
Michael Henry il 17 Apr 2017
Thank you!
Star Strider
Star Strider il 17 Apr 2017
My pleasure!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Mathematics in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by