The error above occurs due to the attempt to use a datetime object as an index, which is not allowed. The issue arises from the month function call when it tries to process the Date variable. To resolve this, the following changes need to be made:
- Remove unnecesary string conversion by directly passing raw.textdata to datetime:
Date = datetime(raw.textdata(2:end, 1), 'InputFormat', 'dd-MMM-yy');
2. Use datestr to directly format the date into 'MMM yy':
m_Labels(i) = datestr(m_Date, 'mmm yy');
Given below is the output after the above corrections: