integration- fzero error
Show older comments
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 Comments
Torsten
on 14 Mar 2016
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
on 14 Mar 2016
Torsten
on 15 Mar 2016
So you used something like
syms Q x
k=int(x*normcfd(x*Q,5,2),x,0,1);
?
Best wishes
Torsten.
Answers (0)
Categories
Find more on Waveform Generation 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!