I have a Nx3 cell array that describes how the rating of an asset ID changes with time. It looks something like this:
{'ID1','01-Jan-2001','A';
'ID1','05-Mar-2003','D';
'ID1','15-Dec-2007','B';
'ID1','15-Dec-2007','B';
'ID1','23-May-2009','A';
'ID2','05-Mar-2003','B';
'ID2','15-Dec-2007','D';
'ID2','29-Apr-2011','A';
'ID3','05-Jun-2003','C';
'ID4','15-Feb-2002','C';
...
The first column is an ID string, the second column is a date string and the third column is a rating string. The columns are sorted first by ID then date. There is one or more rating for each ID.
I want make a split (by modifying the ID) whenever the rating time series shows improvement. The result for the example above would look like this:
{'ID1','01-Jan-2001','A';
'ID1','05-Mar-2003','D';
'ID1_1','15-Dec-2007','B';
'ID1_1','15-Dec-2007','B';
'ID1_2','23-May-2009','A';
'ID2','05-Mar-2003','B';
'ID2','15-Dec-2007','D';
'ID2_1','29-Apr-2011','A';
'ID3','05-Jun-2003','C';
'ID4','15-Feb-2002','C';
...
The ID is modified by appending a number whenever the rating, for a given ID, in a given row, is better than the rating in the previous row.
I have given some thought to a loop-based method of doing this but perhaps there is a much faster way based on logical indexing?