悬赏 10 个论坛币 未解决
求各位帮我看看这个MATLAB CODE 哪需要改?
运行这个CODE 给我的提示是
Error using +
Matrix dimensions must agree.
Error in ft (line 25)
V(:,i+1)=V(:,i) + k*(theta-V_plus)*h + xi*sqr_h*delte_Wv;
%Using the Full trucation scheme to price a European option in the Heston
%Model
K = 100; % Fixed Price
T = 10; % Time
S0 = 100; % Initial asset price
V0 = 0.04; % Initial volatility
k = 0.5; % speed of mean-reversion of the variance
theta = 0,04; %long-term average variance;
xi = 1; % volatility of variance
po = -0.9; % instantaneous correlation between asset price and variance
n = 10; % number of simulation path
h = 1; % number of stepes per year
sqr_h = sqrt(h);
Z1 = randn(n,T); % random number form normal distribution
Z2 = randn(n,T);
Zv = Z1;
delte_Wv = Zv * sqr_h % Winner process of volatility
% Winner process of asset price
delte_Ws = po * delte_Wv + sqrt(1-po^2)* Z2 * sqr_h;
% initialize variances and asset price
V = [V0*ones(n,1),zeros(n,T)]
logS = [log(S0)*ones(n,1),zeros(n,T)];
for i = 1 : n
% fix the negative volatility to 0
V_plus = max(V(:,i),0);
% calculate the volatility
V(:,i+1)=V(:,i) + k*(theta-V_plus)*h + xi*sqr_h*delte_Wv;
% calculate the log asset price
logS(:,i+1)=logS(:,i)-0.5*V_plus*h + sqr_h.*delte_Ws;
end
我应该怎么改下谢谢?