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
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
Nikos P 2016년 3월 14일
i really appreciate that you answer, but i keep getting error in fun even if i use int
Torsten
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개)

질문:

2016년 3월 14일

댓글:

2016년 3월 15일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by