全部版块 我的主页
论坛 提问 悬赏 求职 新闻 读书 功能一区 悬赏大厅
1169 0
2013-07-03
悬赏 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

我应该怎么改下谢谢?

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群