Overcoming 'index exceeds matrix dimensions' without changing methodology of code
1 visualizzazione (ultimi 30 giorni)
This matrix below is a 25x7 matrix. Basically what I'm doing is taking a start date and an end date, and adding 1 to the start date, and subtracting 1 from the end date. The problem is when I get to the last (25th) iteration, where my index exceeds the matrix dimensions. Here the start date is 20081210 and I need to get 20081211. How can I do so without changing the methodology of my code? Thank you.
for i = 1:length(matrix)
[~,startIdx]=ismember(plus1,date); % index days in between entry date and exit date
[~,cutoffIdx]=ismember(minus1,date); % index days in between entry date and exit date
Star Strider il 19 Ago 2015
I don’t entirely undrestand what you’re doing, or what you’re adding or subtracting 1 from. Here are two ways of dealing with dates, the first using datenum and the second creating date vectors:
datevcts = [2008*ones(25,1), 12*ones(25,1), 11*ones(25,1), [[1:25]' zeros(25,2)]];
matrix_dn = datenum(datevcts);
matrix_dv = datevec(matrix_dn);
That may give us a place to begin sorting this.