integration- fzero error
显示 更早的评论
hi i am trying to do this:
fun=@(u,Q) u.*normcdf(u*Q,5,2);
k=quad(@(u) fun(u,Q),0,1);
p=3; r=10; h=6; cd=8; co=1;
f=@(Q) (p+r-h)*k-(p+r-cd)*0.5+co;
fzero(f,0)
But i keep getting these errors: ??? Undefined function or variable 'Q'.
Error in ==> @(u)fun(u,Q)
Error in ==> quad at 76 y = f(x, varargin{:});
Error in ==> newsvendor at 4 k=quad(@(u) fun(u,Q),0,1);
any ideas???
3 个评论
Torsten
2016-3-14
As I already mentionned, "quad" won't give you an integral expression that depends on Q. You will have to explicitly assign a value to Q before calling "quad":
fun=@(u,Q) u.*normcdf(u*Q,5,2);
Q=1;
k=quad(@(u) fun(u,Q),0,1);
Try "int" instead of "quad" to get a symbolic expression for k that depends on Q.
Best wishes
Torsten.
Nikos P
2016-3-14
Torsten
2016-3-15
So you used something like
syms Q x
k=int(x*normcfd(x*Q,5,2),x,0,1);
?
Best wishes
Torsten.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!