How to solve normcdf function error
5 views (last 30 days)
Show older comments
Hi,
I have the following error log:
Error using erf
Input must be real and full.
Error in normcdf (line 47)
p(k) = 0.5 * (1 + erf((x(k) - mu(k)) ./ (sigma(k) * sqrt(2))))_ _
the code used is:
function p = normcdf(x,mu,sigma)
if nargin < 3,
sigma = 1;
end
if nargin < 2;
mu = 0;
end
[errorcode x mu sigma] = distchck(3,x,mu,sigma);
if errorcode > 0
error('The arguments must be the same size or be scalars.');
end
p = zeros(size(x));
k1 = find(sigma <= 0);
if any(k1)
p(k1) = NaN * ones(size(k1));
end
k = find(sigma > 0);
if any(k)
p(k) = 0.5 * (1 + erf((x(k) - mu(k)) ./ (sigma(k) * sqrt(2))));
end
k2 = find(p > 1);
if any(k2)
p(k2) = ones(size(k2));
end
Please could you help me to solve this issue? thanks a lot in advance Irene
1 Comment
Geoff Hayes
on 14 Jan 2015
Edited: Geoff Hayes
on 14 Jan 2015
Irene - how are you calling the normcdf function? What inputs are you using? I noticed that you tagged your question with symbolicnumber. Are you passing a symbol into this function?
Answers (0)
See Also
Categories
Find more on Install Products 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!