Double integration with Range

18 次查看(过去 30 天)
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])

采纳的回答

Star Strider
Star Strider 2017-4-16
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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by