MATLAB: How to select particular timeperiod in timestamp for plotting

timetime series

I have timeperiod from:
startDate = datetime(2020, 3, 22, 23, 0, 0); %initial start date
stopDate = datetime(2020, 3, 31, 03, 0, 0); %stop date
Invdata = databaseconnection(startDate, stopDate); %accessing data from database for that time period and storing in Invdata matrix
So initially, my datapoints length was 70553. I did some data filtering, and now the length is 2351. I want to plot a graph like :
plot(timestamp, datas). But my timestamp length doesnt match with data length. What should I do?
Error message: 'Vectors must be the same length'.

Best Answer

linspace supports datetime() values
startDate = datetime(2020, 3, 22, 23, 0, 0); %initial start date
stopDate = datetime(2020, 3, 31, 03, 0, 0); %stop date
timestamp = linspace(startDate, stopDate, 2351);