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
Best Answer