double integral in MATLAB, limits as variable?
5 ビュー (過去 30 日間)
古いコメントを表示
Hi, Is it possible to do a double integral in MATLAB numerically, where limits are functions of variables?
Say my integrand is
x*y dy * dx
limits are
y=0 to 5x
x = 0 to 5
I can manage this by
syms x y
double(int(int(x*y,y,0,5*x),x,0,5))
But, I think, this is clumsy way. This will get worse for triple integrals. Is there any direct function where we can put limits directly with limits even including variables?
0 件のコメント
回答 (2 件)
madhan ravi
2018 年 7 月 6 日
編集済み: Walter Roberson
2023 年 6 月 17 日
fun = @(x,y) x.*y;
xmin = 0;
xmax = 5;
ymin = 0;
ymax = @(x) 5*x;
Q = integral2(fun,xmin,xmax,ymin,ymax,'Method','tiled')
1 件のコメント
Walter Roberson
2023 年 6 月 17 日
Note that when you use integral2() that the first two limits must be numeric. The third and fourth limits may be either numeric or a function handle with a single parameter. The first two limits apply to the first variable of integration and the third and fourth limits apply to the second variable of integration.
Thus, @madhan ravi has correctly shown an integral2() in which the second variable of integration, y, has an upper bound that is defined by a function handle in terms of the first variable of integration.
If you had a case where the limit on x was defined in terms of y, then y would have to be the first variable of integration, and you would have to be careful about the order of parameters.
integral2(@(FullyIndependent,PartlyDependent) fun(PartlyDependent,FullyIndependent), FullyLower, FullyUpper, PartlyLower, PartlyUpper)
Hussein Thary
2023 年 6 月 17 日
inte
R=1.33e3;no=1;D=2.28e3;L=1330 ;Wo=1e-3
lamda=514.5e-9;k=2*pi/lamda;alfa=1;
f=@(r, fai)exp(-alfa*L./2).*exp(-j*k*r*theata*cos(fai)).*exp((-r^2./w^2)-(j*fai));
f1=Ao.*f;
s=(abs(integral(f1,0,inf,0,2*pi))^2.*(abs(1/j*lamda))^2
plot(r,s)
1 件のコメント
Walter Roberson
2023 年 6 月 17 日
s=(abs(integral(f1,0,inf,0,2*pi))^2.*(abs(1/j*lamda))^2
% 1 2 3 21 2 3 21
Each number indicates the number of levels of open brackets in effect "after" the character above is processed.
So you have 1 open bracket in effect at the end of the line. You should have zero open brackets at the end of the expression.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!