0

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 in minutes on the x-axes on the same plot.

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
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 "normalize" the data set "times" so that the "data" is plotted in the same duration, even though the length of the data sets are different.

Any insights are appreciated.

3
  • Cast all time points to seconds after onset? Commented Sep 25, 2024 at 1:27
  • What does this mean: so that the "data" is plotted in the same duration? Could you mock up what your expected output looks like in Paint (or similar) to clarify how you expect the series to look? Do you expect the x-axis to be the % of time between the first and last time in each series? Commented Sep 25, 2024 at 7:03
  • You are working with time stamps. Such data has been collected in string format. Get it all to minutes right at the beginning and then use histogram to sort data along histogram bins. Doing a histogram with characters is not going to follow the same order as when working directly with minutes only, or better, work it all to seconds and then get minutes before presenting results Commented Sep 28, 2024 at 14:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.