Integral & quadl function gives NaN
Show older comments
Hi everyone,
I am trying to get optimized values by using fmincon function.
In the optimization procedure, a function is integrated with quadl(or integral, alternatively) as following:
quadl(@(e) integProb(e,j,k,Vmat,Vj),a,b,eps1);
where the 'integProb' function looks like:
function [val]=integProb(e,j,k,Vmat,Vj);
%========|=========|=========|=========|=========|=========|=========|=========|
% 10 20 30 40 50 60 70 80
%========|=========|=========|=========|=========|=========|=========|=========|
%
% this function returns the value of the integrand at e
% note that e is a row vector
% matlab function "quad" or "quadl" calls this function for integration
%
%
%========|=========|=========|=========|=========|=========|=========|=========|
% 10 20 30 40 50 60 70 80
%========|=========|=========|=========|=========|=========|=========|=========|
len = length(e);
x=repmat(e+Vj,k,1)-Vmat(:,1:len);
x2 = normcdf(x); % need the sigma of j (the chosen product)
x2(j,:)=1; % we do not need this. See the integrand in our integration eqn
val = prod(x2).* normpdf(e);
the quadl integration function with integProb returns NaN with warning:'Infinite or Not-a-Number function value encountered.' at some values of a, b, Vmat and Vj. but I don't know exactly what their values make quadl function return NaN because those values are decided in the fmincon optimization process. At least, what I can say is that their values near the ones causing NaN returns some values near zero (eg. 1e-10) from quadl function.
Does anyone have any idea on how to troubleshoot this?
I would appreciate any help,
Thank you.
Answers (0)
Categories
Find more on Numerical Integration and Differentiation 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!