fminsearch error.

조회 수: 18 (최근 30일)
gaia buratti
gaia buratti 2011년 7월 23일
Hi, I have built this function
function [ out ] = K_S( par,P) %UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
T=rows(P);
m=par(1,1);
r=par(1,2);
F=par(1,3);
mu0=par(1,4);
sigma0=par(1,5);
alpha=1/(m-1);
M=mu0/alpha;
V=(sigma0/alpha)^2;
for t=1:T
W(t,1)=(P(t,1).*exp(-r*t)-F).^-(m-1); V=(sigma0/alpha)^2;
end dW=W(2:end,1)-W(1:end-1,1); x=sort(dW); cdfvals=cdf('norm',x,M,sqrt(V)); n=length(x); S=(1:n)'/n; %size=size/2;
d=max(abs(cdfvals-S)); %statistic=d; %KS=kolmogorov(dW,0.05,'normcdf',M,sqrt(V));
out=d;
that I should minimize to find the parameters par. par is a vector 1*5.
For that I used fminsearch : [param]=fminsearch(@(par) K_S(par,P),par0);
but it returns a bunch of errors: *??? Error using ==> erfcore Input must be real.
Error in ==> erfc at 23 y = erfcore(x,1);
Error in ==> normcdf at 68 p = 0.5 * erfc(-z ./ sqrt(2));
Error in ==> cdf at 105 p = normcdf(x,a1,a2);
Error in ==> K_S at 24 cdfvals=cdf('norm',x,M,sqrt(V));
Error in ==> @(par)K_S(par,P)
Error in ==> fminsearch at 265 x(:) = y; f = funfcn(x,varargin{:});
I don't understsand why it returns error in the function K_S, since it works perfectly when iI uuse it normally.
There is someone who can help me ??
thanks Gaia

답변 (0개)

카테고리

Help CenterFile Exchange에서 Quadcopters and Drones에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by