Not enough input arguments
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponse acceptée
John Doe
le 11 Mai 2013
Modifié(e) : John Doe
le 11 Mai 2013
How do you call this function?
You need input arguments when running it (you can't press F5 or something similar).
You could also define default arguments to be used if no input is provided:
if nargin < 3
rf = ..
if nargin < 2
t = ..
if nargin < 1
m = ..
end
end
end
Hope it helps =)
- Rob
0 commentaires
Plus de réponses (5)
Kevin van Berkel
le 11 Mai 2013
1 commentaire
John Doe
le 11 Mai 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?
John Doe
le 11 Mai 2013
Modifié(e) : John Doe
le 11 Mai 2013
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;
0 commentaires
Kevin van Berkel
le 11 Mai 2013
1 commentaire
John Doe
le 11 Mai 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 =)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!