Error Using bndprice in Matlab's Financial Toolbox
I'm new to Matlab and reading Numerical Methods in Finance 开发者_运维技巧so this should be a basic question. The code in the book is as follows:
settle = '19-Mar-2000';
maturity = '15-Jun-2015';
face = 1000;
couponRate = 0.05;
yields = 0.01:0.01:0.20;
[cleanPrices , accrInts] = bndprice(yields, couponRate, settle, maturity, 2, 0, [],[],[],[],[],face);
However it returns the following error
??? Error using ==> rdivide Matrix dimensions must agree.
Error in ==> bndprice at 218 PerDisc = 1./(1 + Yield./Frequency);
If I put in a single yield it works fine. Any clue as to why there is an issue with the yields?
you're going to find this ridiculous, but you need to rearrange yields...
[cleanPrices , accrInts] = bndprice(yields', couponRate, settle, maturity, 2, 0, [],[],[],[],[],face);
ahh when the small things go wrong
精彩评论