Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Not Enough Input Arguments
1 回表示 (過去 30 日間)
古いコメントを表示
My problem arises from the very last code below: MATLAB is saying that I do not have enough input arguments. Any feedback as to why this may be would be appreciated.
function y=fixed_rate(fixed)
a=.0347;
c=1;
rho=.2442;
K=100:100:2000;
S0=1065;
T=250;
r=.0125;
N=1000;
VL=.2^2;
epsilon_1=randn(1250,N);
rng(1);
epsilon_2=randn(1250,N);
rng(2);
V = zeros(1250,N);
S = zeros(1250,N);
for i = 1:N
for t = 1:1250
if t == 1
epsilon1 =epsilon_1(t,i) ;
epsilon2 = epsilon_2(t,i);
V(t,i) = VL + c * sqrt((1/T) * abs(VL))* (rho * epsilon1 + sqrt((1 - rho^2) * epsilon2));
S(t,i) = S0 * exp((r - 0.5 * VL)* (1/T) + sqrt((1/T) * VL)* epsilon1);
else
epsilon1 = epsilon_1(t,i);
epsilon2 = epsilon_2(t,i);
V(t,i) = abs(V(t-1,i) + a * (VL - V(t-1,i)) +c*sqrt((1/T) * abs(V(t-1,i)))*(rho * epsilon1 + sqrt((1 - (rho)^2))*epsilon2));
S(t,i) = S(t-1,i) * exp((r - 0.5*V(t-1,i))* (1/T) + sqrt((1/T)*abs(V(t-1,i)))* epsilon1);
end
end
end
for i=1:1000
for t=1:250
num_donom_250(t,i)=(log(S(t+1,i)/S(t,i))^2);
end
end
for i=1:1000
var_250(i)=sum(num_donom_250(:,i));
end
average_var_250=mean(var_250);
for i=1:1000
for t=251:500
num_donom_500(t,i)=(log(S(t+1,i)/S(t,i))^2);
end
end
for i=1:1000
var_500(i)=sum(num_donom_500(:,i));
end
average_var_500=mean(var_500);
for i=1:1000
for t=501:750
num_donom_750(t,i)=(log(S(t+1,i)/S(t,i))^2);
end
end
for i=1:1000
var_750(i)=sum(num_donom_750(:,i));
end
average_var_750=mean(var_750);
for i=1:1000
for t=751:1000
num_donom_1000(t,i)=(log(S(t+1,i)/S(t,i))^2);
end
end
for i=1:1000
var_1000(i)=sum(num_donom_1000(:,i));
end
average_var_1000=mean(var_1000);
for i=1:1000
for t=1001:1249
num_donom_1250(t,i)=(log(S(t+1,i)/S(t,i))^2);
end
end
for i=1:1000
var_1250(i)=sum(num_donom_1250(:,i));
end
average_var_1250=mean(var_1250);
y=(average_var_250-fixed)*exp(-1*r)+((average_var_500-fixed)*exp(-2*r)+(average_var_750-fixed)*exp(-3*r)+(average_var_1000-fixed))*exp(-4*r)+(average_var_1250-fixed)*exp(-5*r);
end
2 件のコメント
回答 (2 件)
Cris LaPierre
2018 年 12 月 5 日
Too many variables missing to run your code. Could you at least copy/paste the entire error message?
What is fixed? It is not defined in the code you included. Is that a function expecting input arguments?
1 件のコメント
Cris LaPierre
2018 年 12 月 5 日
Thank you for updating your code. Running it with dummy data did not produce any error messages. Could you please include
- The line of code you use to call the function
- What value(s) you are using as input to your function
- The entire error message you are seeing
Alan Weiss
2018 年 12 月 6 日
Running your code with the input value 0.01 (for fixed) gives me a complex output. This might be the issue: your code can return non-real output.
Alan Weiss
MATLAB mathematical toolbox documentation
0 件のコメント
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!