integration- fzero error
Afficher commentaires plus anciens
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 commentaires
Torsten
le 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
le 14 Mar 2016
Torsten
le 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.
Réponses (0)
Catégories
En savoir plus sur Waveform Generation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!