Why do I receive the error "??? Index exceeds matrix dimensions." when using the BUSDATE function in the Financial Toolbox 2.1.3 (R12.1)?

Why do I receive the error "??? Index exceeds matrix dimensions." when using the BUSDATE function in the Financial Toolbox 2.1.3 (R12.1)?
I tried defining my own holidays dates using a holidaysEUR file which contains the following values:
730845 730846 730852 730954 730957 730972 731210 731211 731216 731217 731304 731307 731337 731575 731576
After reading in the file, I tried finding the next available business date using BUSDATE:
hEUR = dlmread('holidaysEUR');
datestr(hEUR,1)
datestr(busdate('28-Dec-2001'),1)
datestr(busdate('27-Dec-2001',1,hEUR),1)
busdate('28-Dec-2001',1,hEUR)
But I receive the following error:
??? Index exceeds matrix dimensions.
Error in ==> D\MATLABR12p1\toolbox\finance\calendar\busdate.m
On line 70 ==> bd = reshape(t(in),max([row1 col1;row2 col2])); % find nearest days and resize

 Accepted Answer

This bug has been fixed for Release 14 (R14). For previous releases, please read below for any possible workarounds:
This is a bug in the Financial Toolbox 2.1.3 (R12.1) that has been corrected in the Financial Toolbox 2.3 (R13+.)
This error occurred because the source code for the BUSDATE function looked only at a fixed number of future days in an attempt to determine the next business day. If you passed a HOLIDAYS vector to BUSDATE that contained more consecutive holiday days than BUSDATE searched, or if you asked for the next business day after September 10th, 2001 (after which the stock market was closed for several days), BUSDATE was not able to find a business day in the interval it searched.
As a workaround for versions of the Financial Toolbox prior to version 2.3 (R13+), try changing Line 53 from:
rng = 1:4; % numbers to be added to dates
to:
rng = 1:7; % numbers to be added to dates

More Answers (0)

Community Treasure Hunt

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

Start Hunting!