How to find 1 min of data with inclusion criteria
3 views (last 30 days)
Show older comments
I have a table populated with data. I would like to find 1min of steady state data within this table (the table is a 37x22 table). Steady state is defined as < 5% change in RQ, < 10% change in VE and <10% change in VO2. The outputted data needs to be continuous for the 1min time frame and cannot be split into 10sec at the start and 50sec later. Time is the first column of the table but is represented as a number, I have converted time using a datestr function which has converted into a 37x char array ( I am happy to change this if not functional).
Any suggestions would be fantastic.
0 Comments
Answers (1)
Stephen Jue
on 30 Aug 2016
From what I understand, you want to identify 1-minute-long segments of your data which represents steady state. Are “RQ”, “VE”, and “VO2” columns of your table? Also, what is the time step between each point in the data? Assuming each of these quantities can be accessed as vectors (“RQ”, “VE”, and “VO2”) and your time step is 10 seconds, you can use the following code:
time_step = 10; % seconds
num_rows = 37;
rows_per_minute = 60 / time_step;
percent_change = @(x) 100 * abs((x - x(1)) / x(1));
steady_data_indices = [];
% Set up dummy data for RQ, VE, and VO2
a = 90; b = 100;
RQ = (b-a) .* rand(1, num_rows)' + a;
VE = (b-a) .* rand(1, num_rows)' + a;
VO2 = (b-a) .* rand(1, num_rows)' + a;
for i = 1:(num_rows - rows_per_minute) % sliding window
RQ_percent_change = percent_change(RQ(i:i+rows_per_minute));
VE_percent_change = percent_change(VE(i:i+rows_per_minute));
VO2_percent_change = percent_change(VO2(i:i+rows_per_minute));
if all(RQ_percent_change < 5) && all(VE_percent_change < 10) && all(VO2_percent_change < 10)
steady_data_indices = [steady_data_indices i];
end
end
This code takes a 1-minute-long “window” and slides it through the data, checking the percent deviation of “RQ”, “VE” and “VO2” from the first value of the window to make sure they are within the bounds you specified. After the for loop completes, “steady_data_indices” will contain all of the starting indices where there is a 1-minute-long segment of steady state data.
Depending on how you define percent change, you may need to use a different function handle for “percent_change”, but hopefully this helps you get started.
2 Comments
Stephen Jue
on 8 Sep 2016
Edited: Stephen Jue
on 8 Sep 2016
Hi Teresa,
Yes, that is correct. My code only gave an example with dummy data for "RQ", "VE", and "VO2". You will need to modify it by using the columns of your table that correspond to those three variables.
For example, if "RQ" corressponds to column 11 on your table, you could define it as
RQ = RestTable(:,11);
Also, depending on the time step of your data, you may need to change "time_step"
See Also
Categories
Find more on Tables 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!