Not enough input arguments
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
John Doe
2013년 5월 11일
편집: John Doe
2013년 5월 11일
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
추가 답변 (5개)
Kevin van Berkel
2013년 5월 11일
댓글 수: 1
John Doe
2013년 5월 11일
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
2013년 5월 11일
편집: John Doe
2013년 5월 11일
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
Kevin van Berkel
2013년 5월 11일
댓글 수: 1
John Doe
2013년 5월 11일
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 =)
참고 항목
카테고리
Help Center 및 File Exchange에서 Time Series Collections에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!