l54tianya 发表于 2007-12-19 15:14

用matlab实现JC法出错求助

Miu_R=100;
Sigma_R=12;

Miu_S=50;
Sigma_S=7.5;
syms R S Ibeta
g=R-S;

R_cos=-diff(g,R).*Sigma_R./sqrt((diff(g,R).*Sigma_R)^2+(diff(g,S).*Sigma_S)^2);
S_cos=-diff(g,S).*Sigma_S./sqrt((diff(g,R).*Sigma_R)^2+(diff(g,S).*Sigma_S)^2);


% Iteration 1
R_star=Miu_R;
S_star=Miu_S;

Arfa_R=subs(R_cos,{R,S},{Miu_R,Miu_S });
Arfa_S=subs(S_cos,{R,S},{Miu_R,Miu_S});

F=50-12.*beta.*Arfa_R+7.5.*beta.*Arfa_S;
beta1=solve(F,beta);
beta_s=beta1(1);
for i=2:1000
R_star=Miu_R-Arfa_R.*beta_s.*Sigma_R;
S_star=Miu_S-Arfa_S.*beta_s.*Sigma_S;


Arfa_S=subs(S_cos,{R,S},{R_star,S_star});
Arfa_R=subs(R_cos,{R,S},{R_star,S_star });
F=50-12.*beta.*Arfa_R+7.5.*beta.*Arfa_S;

beta2=solve(F,beta);
beta(i)=beta2(1);
p=eval(abs(beta(i)-beta_s));
if p>1e-4;
beta_s=beta(i);
break
end
Pf=norminv(-beta(i),0,1);
disp('R_star','S_star','beta2(1)','Pf');
end

Error in ==> d:\MATLAB6p5\work\Untitled3.m
On line 32==> Pf=norminv(-beta(i),0,1);
这里一直出错,各位帮帮忙啊.

[ 本帖最后由 eight 于 2007-12-19 15:59 编辑 ]

花如月 发表于 2007-12-19 15:23

请帖完整错误信息

sigma665 发表于 2007-12-19 15:36

我运行了下,出现这个错误
我的是7。5的,

??? Error using ==> beta at 21
Not enough input arguments.

估计你的bata不是调用matlab自带的bata函数吧   

如果不是的话,把bata换个名字。

[ 本帖最后由 sigma665 于 2007-12-19 15:39 编辑 ]

eight 发表于 2007-12-19 16:00

原帖由 l54tianya 于 2007-12-19 15:14 发表 http://www.chinavib.com/forum/images/common/back.gif
Miu_R=100;
Sigma_R=12;

Miu_S=50;
Sigma_S=7.5;
syms R S Ibeta
g=R-S;

R_cos=-diff(g,R).*Sigma_R./sqrt((diff(g,R).*Sigma_R)^2+(diff(g,S).*Sigma_S)^2);
S_cos=-diff(g,S).*Sigma_S./sqr ...

下次发帖前,请先认真阅读置顶帖
页: [1]
查看完整版本: 用matlab实现JC法出错求助