1)Error using integral2ParseArgs (line 13)Expected a string for the parameter name,instead the input was 'double' 2)Error in integral2 (line 104) opstruct = integral2ParseArgs(isImproper,varargin{:}); I am getting these two errors.what should bedone
5 次查看(过去 30 天)
显示 更早的评论
pdf=N*exp(-N.*x);
xmin=0;
xmax=b;
ymin=0;
ymax=inf;
f=@(x,y)log(1+((Zt.*y).\(Zs.*x)+1))+log(1+((Zt.*y).\(Zi+1))).*pdf;
A= integral2(f,y,ymin,ymax,x,xmin,xmax);
2 个评论
madhan ravi
2018-9-7
Provide all the details which was not defined in the code above and update it so that we could test it ?
回答(1 个)
Walter Roberson
2018-9-7
q = integral2(fun,xmin,xmax,ymin,ymax)
Notice that variable name is not passed as part of the bounds and that you cannot pass y boundaries before x boundaries.
Symbolic integration requires that the name of the variable be passed before the bound but numeric integration is fixed order
1 个评论
Walter Roberson
2018-9-8
I stand by my response. You should not be passing in the variable name for integral2().
You can use
B = integral2(@(y,x) fun1(x,y), ymin, ymax, xmin, xmax)
if you need the y to be the "inner" variable for integration.
Order that the parameters vary should not matter if the bounds are fixed: it should only matter if the bounds are expressed in terms of each other. For example,
integrate fun1(x,y) over y = 0 to 5, x = 0 to sin(y)^2
then in that case the x passed into fun1 would have to be the second set of bounds because integral2 can accept functions handles for the second set of bounds but not for the first:
B = integral2(@(y,x) fun1(x,y), 0, 5, 0, @(y) sin(y).^2)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dynamic System Models 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!