Plotting datetime from dataset

2 Ansichten (letzte 30 Tage)
Kassidy Rose Sharits
Kassidy Rose Sharits am 5 Jun. 2020
Bearbeitet: per isakson am 5 Jun. 2020
I have a two-column data set that I would like to plot. The data I would like to plot on the x-axis is datetime in the format yyyy-MM-dd refer to attached picture). What to I need to do to be able to plot the dates? I have not been able to find how to change them all into the correct format altogether, is this possible?

Antworten (1)

per isakson
per isakson am 5 Jun. 2020
Bearbeitet: per isakson am 5 Jun. 2020
You may specify the format of the time axis in the plot command. See the documentation of plot()
%% Create some data that resambles your image
vec = zeros( 14, 3 );
vec(:,1) = 2010;
vec(:,2) = 1;
vec(:,3) = reshape([1:14],[],1);
y = randi([30,36],14,1);
DT = datetime( vec );
%%
lh = plot( DT, y, 'd', 'DatetimeTickFormat','yyyy-MM-dd' );

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by