Not enough input arguments
Mostra commenti meno recenti
Hi all,
the following code yields me this error:
Not enough input arguments in line 1.
this is the code:
function [Re] = varmom(m,t,rf);
epsilon = zero(m,t,rf);
r = zeros(m,t);
for m=1:M;
epsilon(m,:,:) = mvnrnd(0, [0.006,-0.0051],t);
end
for m =1:M
r(m,1)=0.227+ epsilon(m,1,1)
for i = 1:T-1;
r(m,i+1) = 0.027 + epsilon(m,i+1,1);
end
end
%create excess return out of log excess return
Re = rf*exp(r)-rf;
Where m is #simulations, t is timehorizon and rf is a constant riskfree rate.
Something should be wrong in line one but I don't know how to fix it.
Any suggestions?
Cheers.
Risposta accettata
Più risposte (5)
Kevin van Berkel
il 11 Mag 2013
0 voti
Kevin van Berkel
il 11 Mag 2013
1 Commento
John Doe
il 11 Mag 2013
I just noticed zeros(M,T,rf). As rf is not an integer, this is not good. Which dimension do you want it to have?
Use lower case m, or some other letter that can't be mixed with upper case M, as indices in your for-loops, and you'll get there =)
if nargin < 3
rf = 1.06
if nargin < 2
T = 20
if nargin < 1
M = 1000
end
end
end
epsilon = zeros(M,T,rf);
r = zeros(M,T);
for ii=1:M;
epsilon(ii,:,:) = mvnrnd(0, [0.006],T);
end
for jj =1:M
r(jj,1)=0.227+ epsilon(jj,1,1)
for kk = 1:T-1;
r(jj,kk+1) = 0.027 + epsilon(jj,kk+1,1);
end
end
%create excess return out of log excess return
Re = rf*exp(r)-rf;
Kevin van Berkel
il 11 Mag 2013
1 Commento
John Doe
il 11 Mag 2013
I'm an electrical engineer and haven't got a clue what you're asking for, sorry about that... Glad I could help out with the programming part though =)
Kevin van Berkel
il 11 Mag 2013
0 voti
Categorie
Scopri di più su Programming in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!