是否可以使用integral2 / integral3进行分段常数函数?

时间:2017-05-16 15:12:51

标签: matlab integral

我已经定义了以下参数:

sigma=@(u)0.2.*((0<=u) && (u<1))+0.3.*((1<=u) && (u<2));
alpha=@(u)0.1.*((0<=u) && (u<1))+0.4.*((1<=u) && (u<2));
lambda=3;

if lambda==0
    E1Integrand=@(T,u,a)...
    (-1.*(T-u).*exp(-1.*lambda.*(T-u))).^2.*...
    (-1.*(T-a).*exp(-1.*lambda.*(T-a))).*...
    sigma(u).^2.*alpha(a).*sigma(a);
else
    E1Integrand=@(T,u,a)...
    ((1-exp(-1.*lambda.*(T-u)))./lambda).^2.*...
    ((1-exp(-1.*lambda.*(T-a)))./lambda).*...
    sigma(u).^2.*alpha(a).*sigma(a);
end
E1Integrand_amax=@(u)u;
E1Integral=integral2(NewE1Integrand,0,1.5,0,E1Integrand_amax);

我想为分段常数函数做双积分。但是,会出现以下错误消息:

Operands to the || and && operators must be convertible to logical scalar values.
Error in @(u)0.2.*((0<=u)&&(u<1))+0.3.*((1<=u)&&(u<2))
Error in
@(T,u,a)((1-exp(-1.*lambda.*(T-u)))./lambda).^2.*((1-exp(-1.*lambda.*(T-
a)))./lambda).*sigma(u).^2.*alpha(a).*sigma(a)
Error in @(u,a)E1Integrand(0.2,u,a)
Error in integral2Calc>integral2t/tensor (line 228)
       Z = FUN(X,Y);  NFE = NFE + 1;
Error in integral2Calc>integral2t (line 55)
[Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT);
Error in integral2Calc (line 9)
[q,errbnd] = integral2t(fun,xmin,xmax,ymin,ymax,optionstruct);
Error in integral2 (line 106)
Q = integral2Calc(fun,xmin,xmax,yminfun,ymaxfun,opstruct);

我想知道如何修复它,或者integral2不能用来整合分段常数函数。

0 个答案:

没有答案