matlab编程问题,S0=50;K=5;r=0.2;sigma=0.3;T=0.5;a=428.5912b=246.7252c=-801.6449for 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; and 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
来源:学生作业帮助网 编辑:作业帮 时间:2024/12/01 07:41:57
matlab编程问题,S0=50;K=5;r=0.2;sigma=0.3;T=0.5;a=428.5912b=246.7252c=-801.6449for 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; and 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
matlab编程问题,
S0=50;
K=5;
r=0.2;
sigma=0.3;
T=0.5;
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;
and 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
A
B
S0=50;
K=5;
r=0.2;
sigma=0.3;
T=0.5;
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;
and 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
A
B
a =
428.5912
b =
246.7252
c =
-801.6449
Error using &
Inputs must have the same size.
不知道错误在哪里,
matlab编程问题,S0=50;K=5;r=0.2;sigma=0.3;T=0.5;a=428.5912b=246.7252c=-801.6449for 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; and 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
if A(i,j)>K;
and b*A(i,j)+c *(A(i,j)^2)-A(i,j)>-K-a;
if A(i,j)>K;
and b*A(i,j)+c *(A(i,j)^2)-A(i,j)>-K-a;
这两句 改一下吧
if( (A(i,j)>K) && (b*A(i,j)+c *(A(i,j)^2)-A(i,j)>-K-a) )