MATLAB Answers

0

How to plot data as a time series in a figure

Asked by Haider Ali on 29 Oct 2019
Latest activity Commented on by Haider Ali on 30 Oct 2019
HI,
I have a text file and I would like to plot the data as a time series in a figure.

  0 Comments

Sign in to comment.

1 Answer

Answer by Akira Agata
on 30 Oct 2019
 Accepted Answer

How about the following?
T = readtable('data.txt','HeaderLines',3,'ReadVariableNames',false);
T.Properties.VariableNames = {'TIME_BEGIN','TIME_END','TEMPERATURE'};
T.TIME_BEGIN = datetime(num2str(T.TIME_BEGIN),'Format','yyyyMMdd');
T.TIME_END = datetime(num2str(T.TIME_END),'Format','yyyyMMdd');
Time = reshape(T{:,{'TIME_BEGIN','TIME_END'}}',[],1);
Temperature = repelem(T.TEMPERATURE,2,1);
figure
plot(Time,Temperature)
ylabel('Temperature','FontSize',16)
temperature.png

  2 Comments

Its good. If , I would like to increase the number of years on X-asix. THen what should I change?
HI Akira,
I have sent you a message. I need to plot some more data. KIndly reply me back. Thanks a lot

Sign in to comment.