Plotting two curves on a Datetime scale.
Show older comments
Data 1
Coloumn 1(Datetime) Coloumn 2 (Temperature)
'2019-07-03T16:06:48' 24
'2019-07-03T16:08:48' 24
'2019-07-03T16:09:48' 25
'2019-07-03T16:10:48' 25
'2019-07-03T16:11:48' 25
'2019-07-03T16:12:48' 25
'2019-07-03T16:13:48' 25
'2019-07-03T16:14:48' 25
'2019-07-03T16:15:48' 25
'2019-07-03T16:16:48' 25
'2019-07-03T16:17:48' 25
'2019-07-03T16:18:48' 25
'2019-07-03T16:19:48' 25
'2019-07-03T16:20:48' 25
'2019-07-03T16:21:48' 25
Data 2
Coloumn 1(Time) Coloumn 2 (Temperature)
0 25
20 24.7714
40 24.5304
60 24.2764
80 24.0096
100 23.7305
120 23.4398
140 23.1384
160 22.8269
180 22.5061
200 22.177
220 21.8401
240 21.4962
260 21.1459
280 20.7899
%% Loading the datas :
load('In_Flight_Data.mat');
% Start and end dates for real-time datas obtained
DateStart = datetime('03/07/2019 17:00:00','InputFormat','dd/MM/uuuu HH:mm:ss');
DateEnd = datetime('04/07/2019 08:00:00','InputFormat','dd/MM/uuuu HH:mm:ss');
% Datas index you want to plot
idToPlot = [17];
% Figure initialisation
figure
hold on
leg = {};
% Loop to plot the datas one by one
for i = 1:numel(idToPlot)
idat = idToPlot(i);
% Find the measurement points that are between the start and en dates
id = find((dataTot(idat).Date > DateStart) & (dataTot(idat).Date < DateEnd));
% Plot the data
plot(dataTot(idat).Date(id),dataTot(idat).Value(id));
% Put some text in the leg array, which will be used as legend
leg{end+1} = dataTot(idat).Name;
end
% Format the graph
legend(leg); % give a ledgend
ylabel('Temperature (°C)'); % Give a label to Y axis
title('Temperatures'); % Give a title
Hello Everyone,
I would like to plot these two datas (Data 1 and Data 2) on the same plot. But one has time in datetime format and one in seconds, how do i do this? I have a code which I have posted above with which I plotted the datetime data (Data1). "idToPlot = [17];" This line simply is the index number given to a particular component for which the Datetime datas have been plotted.
Le version en Français
Bonjour à tous, Je voudrais tracer ces deux données (Data 1 et Data 2) sur le même plot. Mais on a l'heure au format datetime et l'autre en secondes, comment faire? j'ai un code que j'ai posté ci-dessus avec lequel j'ai tracé les données datetime (Data1). "idToPlot = [17];" Cette ligne est simplement le numéro d'index attribué à un composant particulier pour lequel les données Datetime ont été tracées.
2 Comments
dpb
on 14 Dec 2019
Either add a reference start time to the elapsed times of the second set or subtract the initial time from the datetime value of the first to create a duration.
Accepted Answer
More Answers (0)
Categories
Find more on JSON Format in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!