Clear Filters
Clear Filters

How to find 1 min of data with inclusion criteria

1 view (last 30 days)
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.

Answers (1)

Stephen Jue
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
Teresa Phillips
Teresa Phillips on 6 Sep 2016
Thanks.
From what I can gather the steady_data_indices is the row where the 1min of steady state data starts. Is this correct?
From here I would like to calculate mean and SD of the steady state zones (the 1min period).
The steady_data_indices has reported as 8,14,23,28 in a double Sorry to be naive but how has this code accessed my data? The data is sitting in a table names RestTable
Stephen Jue
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"

Sign in to comment.

Categories

Find more on Tables in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!