Привет, у меня есть следующий код Matlab.Жалуется на:
???Входной аргумент "r" не определен.
Ошибка в ==> BlackScholesPriceTmp при 8 b = r;
Код:
%function [price,delta,gamma,vega,theta]=BlackScholesPriceTmp(CallPutFlag,S,X,T,r,v,noutparams)
function [price,delta,gamma,vega,theta]=BlackScholesPriceTmp(CallPutFlag,S,X,T,r,v,noutparams)
delta=0;
gamma=0;
vega=0;
theta=0;
b=r;
d1 = (log(S / X) + (b + v ^ 2 / 2) * T) / (v * T^0.5);
d2 = d1 - v * T^0.5;
price=0;
if CallPutFlag == 'c' ,
price = S * normal_cdf(d1) - X * exp(-r * T) * normal_cdf(d2);
%endif
end
if noutparams>1,
delta=exp((b-r)*T)*normal_cdf(d1);
theta_tmp1= -( S*exp((b-r)*T)*normal_pdf(d1)*v )/(2*T^0.5);
theta_tmp2= -(b-r)*S*exp((b-r)*T)*normal_cdf(d1);
theta_tmp3= -r*X*exp(-r*T)*normal_cdf(d2);
theta=theta_tmp1+theta_tmp2+theta_tmp3;
%end
%endif
else
%price = X * exp(-r * T) * normal_cdf(-d2) - S * normal_cdf(-d1);
price = X * exp(-r * T) * normalcdf(-d2) - S * normcdf(-d1);
end
if noutparams>1,
delta=exp((b-r)*T)*(normal_cdf(d1)-1);
theta_tmp1= -( S*exp((b-r)*T)*normal_pdf(d1)*v )/(2*T^0.5);
theta_tmp2= (b-r)*S*exp((b-r)*T)*normal_cdf(-d1);
theta_tmp3= r*X*exp(-r*T)*normal_cdf(-d2);
theta=theta_tmp1+theta_tmp2+theta_tmp3;
endif
end
if noutparams>1,
gamma=(normal_pdf(d1)*exp((b-r)*T)) / (S*v*T^0.5);
vega=S * exp((b-r)*T)*normal_pdf(d1)*T^0.5;
endif
end
Как новичок в Matlab,почему он жалуется на параметр r, а не на остальные.Я не понимаю, почему другие жалуются?Что я делаю правильно в остальном, но не в г?