C++:

```
%--------------------------------------------------------------------------
% @description: Attempt to estimate the parameter of the market price
% of risk, lamda of the Vasicek model 1977 of the term structure
%model of yields. We do this by using curve fitting to the observed data.
%
% Xdata: - vector of times to maturity .
% ydata - vector of observed yields-to-maturity that correspond to
% the matching value by the yields-to-maturity correspinf to
% the vasicek model wich has the following form:
% R(T) = R(alpha) +(r0 - (beta - R(alpha)) *
% (1- exp (- beta*T))/ (beta *T) +
% ((sigma^2)*(1- exp (- beta*T))^2)/(4*(beta^3)*T).
%
%
%where R(alpha)= (beta - ((lamda * sigma)/ alpha)- ((sigma^2)/ (2*(alpha^2)))
% and T is time to maturity.
%
% xdata = [0.5 1 2 3 5 7 10];
% ydata =[0.079 0.0782 0.0791 0.0793 0.0791 0.0802 0.0798];
%--------------------------------------------------------------------------
xdata = ...
[0.5 1 2 3 5 7 10];
ydata = ...
[0.079 0.0782 0.0791 0.0793 0.0791 0.0802 0.0798];
alpha = 0.051356;
beta = 0.1374;
sigma = 0.0118;
r = 0.012;
lamda0 = - 0.031; % Starting guess%
Function F = myfun(lamda,xdata);
F = Ralpha +((1-exp(-beta*xdata))/(beta*xdata))*(r-Ralpha)+...
((sigma.^2)/(4*(beta.^3)*xdata)*((1-exp(-xdata)).^2));
Ralpha =(beta -(lamda*sigma)/alpha)-(sigma.^2)/(2*(alpha.^2));
[x,resnorm] = lsqcurvefit(@myfun,lamda0,xdata,ydata);
plot (xdata,ydata,lsqcurvefit);
```

??? Attempt to execute SCRIPT function as a function:

C:\Program Files\MATLAB\R2009a\toolbox\matlab\lang\function.m

Error in ==> fit at 33

Function F = myfun(lamda,xdata);

please can you help me the resolve the problem