Not enough input arguments
5 ビュー (過去 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!