How to plot Date time series in MATLAB?

I
isabellewilliams · Jan 4, 2021 · 2.1K views
Question
I am facing difficulties in  plotting my time series data. I write code like this but doesnt work.   data3=readtable ('PRICE_AND_DEMAND_Jan.csv') Date_Time = data3(:,2); datecell=table2cell(Date_Time); load = data3(:,3); A = table2array(load) p=datenum(datecell); plot(datenum(datecell), A) datetick('x', 'dd-mmm-yyyy HH:MM:SS') % datetick('x', 'dd-mmm-yyyy HH:MM:SS')
Expert Answer
Profile picture of John Williams
John Williams PhD Expert
Answered Aug 24, 2026

try  it:

 

data3=readtable ('PRICE_AND_DEMAND_Jan.csv')
Date_Time = data3(:,2);
datecell=table2cell(Date_Time);
load = data3(:,3);
A = table2array(load)
formatIn='dd-mm-yy HH:MM'
p=datenum(datecell,formatIn);
plot(p, A)
datetick('x', 'dd-mmm-yyyy HH:MM')
set(gca,'XTickLabel',datestr(p),'XMinorGrid','on')
grid
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!