MATLAB: Specific timestamp to date format using datetime

MATLABtimestampuserdefined

I have data with a certain timestamp, being yyyymmddHHMM and I want to convert this to time format in matlab:
For example:
Given a timestamp of 201502171000 I want to get 2015-02-17 10:00.
PS: I have to manage a lot of data for a given time unit and my aim is to identify my measurements for that certain time unit. And thats why I thought that time format could be helpful.

Best Answer

This works:
T = 201502171000;
str = num2str(T, '%11d');
dn = datenum(str, 'yyyymmddHHMM');
ds = datestr(dn, 'yyyy-mm-dd HH:MM') % ‘Legacy’ Functions
dt = datetime(str, 'InputFormat','yyyyMMddHHmm', 'Format','yyyy-MM-dd HH:mm') % ‘datetime’ Function
I do not know if you are starting with an integer or string, so I included the conversion from integer to string, necessary for the datetime function.