Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Not Enough Input Arguments

1 回表示 (過去 30 日間)
Andrew Souphis
Andrew Souphis 2018 年 12 月 5 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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 件のコメント
Stephen23
Stephen23 2018 年 12 月 5 日
編集済み: Stephen23 2018 年 12 月 5 日
@Andrew Souphis: please show us in a new comment (not an answer) the complete error message. This means all of the red text.
Andrew Souphis
Andrew Souphis 2018 年 12 月 5 日
Not enough input arguments.
Error in dr_final_b (line 106)
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);

回答 (2 件)

Cris LaPierre
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
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
  1. The line of code you use to call the function
  2. What value(s) you are using as input to your function
  3. The entire error message you are seeing

Alan Weiss
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

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by