フィルターのクリア

function itself does not work but each part on its own does

3 ビュー (過去 30 日間)
Mario
Mario 2013 年 8 月 13 日
Hi all. I just started programming in MatLab and faced the problem that the following function does not work but running each part on its own surprisingly does. Any help?
function w = we(index, maturity, tenorDate) %weights
helper= cumprod(1./(1+rates(maturity:tenorDate-1)));
nom = helper(index-maturity+1);
denom = cumsum(helper);
w = nom./denom(tenorDate-maturity);
end
whereby:
index = [6 7 8 9 10];
maturity= 6;
tenorDate=11;
rates = [0.0299 0.0366 0.0410 0.0444 0.0475 0.0497 0.0514 0.0522 0.0530 0.0540]'
Thanks a lot
  1 件のコメント
Matt J
Matt J 2013 年 8 月 13 日
I don't get any error messages when I run the code.

サインインしてコメントする。

採用された回答

the cyclist
the cyclist 2013 年 8 月 13 日
編集済み: the cyclist 2013 年 8 月 13 日
You haven't included rates as an input to the function.
  2 件のコメント
Mario
Mario 2013 年 8 月 13 日
編集済み: the cyclist 2013 年 8 月 13 日
Thank you for the answer. using your answer, why does the following function (which uses the function above) not work?
function F = F_Star(maturity, tenorDate, rates, weights)
F = rates(maturity:tenorDate-1)*weights(maturity:tenorDate-1, maturity, tenorDate, rates);
end
the cyclist
the cyclist 2013 年 8 月 13 日
編集済み: the cyclist 2013 年 8 月 13 日
Guessing here, but you probably wanted to use " .* " rather than " * " for the multiplication.
In the future, it's best if you write the whole code that you are trying to execute, as well as the full error message you are getting.
Also, it is usually better to open a second question (possibly referring back to the first one), rather than bury a followup question in the comments. More people will see it that way.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by