mHelpMe
mHelpMe

Reputation: 6668

convert vector of date numbers to cell array

I have a vector called dates_index which is a 310 x 1 of type double. I want to convert the numbers to their string representation i.e 14-Jul-2014.

When I use the datestr(dates_index) it returns me a 310 x 11 char type which is not what I would like. I would like a 310 x 1 cell array.

Upvotes: 1

Views: 585

Answers (2)

herohuyongtao
herohuyongtao

Reputation: 50717

You can further use cellstr() to create strings from character array:

cellstr(datestr(dates_index))

Upvotes: 1

m_power
m_power

Reputation: 3204

As proposed, here an example:

DateVector = [731878; 731879; 731880; 731881; 731882; 731883];
A = cellstr(datestr(DateVector));

A is a 6x1 cell.

Upvotes: 1

Related Questions