Duration of time values for separate datasets and plotting on x-axis
Ältere Kommentare anzeigen
I have the following data sets that have in the x-axis time in "HH:mm:ss". Each data set has different numbers of "times" but they are all within a 2hr duration.
I want to plot this data in terms of duration on the same axes.
Sorry this is the update data.
set0_time=["085440","091530","092000","093020","100000","100020","101325"];
set0_ydata=[30 50 60 72 82 85 88];
H_set0 = str2double(extractBefore(set0_time(:),3));
M_set0 = str2double(extractBetween(set0_time(:),3,4));
S_set0 = str2double(extractAfter(set0_time(:),4));
D_set0 = duration(H_set0,M_set0,S_set0);
t_minutes_set0 = minutes(D_set0);
set1_time = ["121101","121105","130001","133025","140000"];
set1_ydata=[40 50 60 70 89];
H_set1 = str2double(extractBefore(set1_time(:),3));
M_set1 = str2double(extractBetween(set1_time(:),3,4));
S_set1 = str2double(extractAfter(set1_time(:),4));
D_set1 = duration(H_set1,M_set1,S_set1);
t_minutes_set1 = minutes(D_set1);
tdiff_minutes_set1 = t_minutes_set1 - t_minutes_set0(1:5); %There is an issue selecting the first five of set0 as the shift is not accurate
tdiff_shift_set1 = t_minutes_set1-tdiff_minutes_set1;
set2_time = ["103235","110010","120000","130130"];
set2_ydata=[37.8 70 85.7 93.6];
H_set2 = str2double(extractBefore(set2_time(:),3));
M_set2 = str2double(extractBetween(set2_time(:),3,4));
S_set2 = str2double(extractAfter(set2_time(:),4));
D_set2 = duration(H_set2,M_set2,S_set2);
t_minutes_set2 = minutes(D_set2);
tdiff_minutes_set2 = t_minutes_set2 - t_minutes_set0(1:4); %There is an issue selecting the first four of set0 as the shift is not accurate
tdiff_shift_set2 = t_minutes_set2-tdiff_minutes_set2;
figure(15)
scatter(t_minutes_set0,set0_ydata,'Marker','o', 'DisplayName','set0') %updated this line
hold on;
scatter(tdiff_shift_set1,set1_ydata,'Marker','*', 'DisplayName','set1')
scatter(tdiff_shift_set2,set2_ydata,'Marker','+', 'DisplayName','set2')
hold off
xlabel('Duration');
ylabel('Data');
legend
I'm not sure how to get all the data on the same plot but in the same "duration" of time.
Any help is appreciated.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Time Series Events finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
