Double integration with Range

14 ビュー (過去 30 日間)
Michael Henry
Michael Henry 2017 年 4 月 16 日
コメント済み: Star Strider 2017 年 4 月 17 日
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 件のコメント
Michael Henry
Michael Henry 2017 年 4 月 17 日
Thank you!
Star Strider
Star Strider 2017 年 4 月 17 日
My pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by