I try to get an integral of two function handles in Matlab. The first function handle would be a weibull probability density function and the second function handle is based on a cfit I created with linear interpolation of single points.
x = 0:0.1:35;
fun1 = @(x) wblpdf(x,weibullAlpha,weibullBeta);
fun2 = @(x) feval(cfitObject,x);
fun3 = @(x) (fun(x).*fun2(x));
y = integral(fun3,0,35); % Using quad(fun3,0,35) doesn t work either.
我收到以下错误:
Error using integralCalc/finalInputChecks (line 515)
Output of the function must be the same size as the input. If FUN is an array-valued integrand,
set the ArrayValued option to true.
Error in integralCalc/iterateScalarValued (line 315)
finalInputChecks(x,fx);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in test (line 7) % "test" is the name of the script file.
y = integral(fun3,0,35);
问题必须涉及“fun2”,因为《刑法》只是罚款。
fun2 = x.^2;
注:如果我用布局图2。 目标我没有错误。 还可使用四(四)项整合这一职能。
x = 0:0.1:35;
fun2 = @(x) feval(cfitObject,x);
y = quad(fun2,0,35);
plot(x, fun2(x))
任何帮助都受到高度赞赏。