Double integration with Range

조회 수: 3 (최근 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개)

Community Treasure Hunt

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

Start Hunting!

Translated by