Not Enough Input Arguments
Info
This question is closed. Reopen it to edit or answer.
Show older comments
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 Comments
@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
on 5 Dec 2018
Answers (2)
Cris LaPierre
on 5 Dec 2018
0 votes
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 Comment
Cris LaPierre
on 5 Dec 2018
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
on 6 Dec 2018
0 votes
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
This question is closed.
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!