matlab编程问题 ,不知哪里出错
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/11 14:46:34
matlab编程问题 ,不知哪里出错
S0=50;
K=5;
r=0.2;
sigma=0.3;
T=0.5;
q=0;
random_A=randn(1000);
a=428.5912
b=246.7252
c=-801.6449
for i=1:10;
for j=1:100;
A(i,j)=S0*exp((r-sigma^2/2)*T+sigma*random_A(i,j)*sqrt(T));
if A(i,j)>K;
b*A(i,j)+c *(A(i,j)^2)-A(i,j)>-K-a;
B(i,j)=0;
else B(i,j)=a +b*A(i,j)+c*(A(i,j) ^2);
end
end
end
B
B
Columns 1 through 14
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
Columns 99 through 100
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
不懂为什么全是0?
S0=50;
K=5;
r=0.2;
sigma=0.3;
T=0.5;
q=0;
random_A=randn(1000);
a=428.5912
b=246.7252
c=-801.6449
for i=1:10;
for j=1:100;
A(i,j)=S0*exp((r-sigma^2/2)*T+sigma*random_A(i,j)*sqrt(T));
if A(i,j)>K;
b*A(i,j)+c *(A(i,j)^2)-A(i,j)>-K-a;
B(i,j)=0;
else B(i,j)=a +b*A(i,j)+c*(A(i,j) ^2);
end
end
end
B
B
Columns 1 through 14
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
Columns 99 through 100
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
不懂为什么全是0?
if A(i,j)>K;
b*A(i,j)+c *(A(i,j)^2)-A(i,j)>-K-a;
B(i,j)=0;
所给条件一直符合这段程序,所以结果为0
b*A(i,j)+c *(A(i,j)^2)-A(i,j)>-K-a;
B(i,j)=0;
所给条件一直符合这段程序,所以结果为0