句柄函数里套句柄函数的情况。
Show older comments
定义了一个句柄函数,里面包括一个积分,积分里面也含有句柄函数,代码如下:
D=500;p=1/1000;Dcoe=5;Ab=50;Av=80;hb=10;hv=6;backcost=200;a=1;b=4;c=1;
f=@(q,k,m)(Av*D/(m*q)+hv*q*(m*(1-D*p)-1+2*D*p)/2+Ab*D/q+hb*(q/2+k*Dcoe*sqrt(a*(b-q)^2+c))+backcost*D*Dcoe*sqrt(a*(b-q)^2+c)*integral(@(z,k)normpdf(z,0,1),k,inf)/q)
定义好后,直接带入具体数值可以算出函数值。但若将矩阵带入,则会出现异常情况。例如:
定义A=[1,2,3;4,5,6], 将A的第一列带入函数,命令f(E(1,1:3))会出现错误,而直接f(1,2,3)却没有错,报错原因为:
Not enough input arguments
请问这是为何?
Accepted Answer
More Answers (0)
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!