Averaging across labels in a time-series data
Hi, I have a time series data that loos like this:
time = repmat(5, 10, 1);
stages = {‘A’, ‘B’, ‘C’};
stage = stages(randi(numel(stages), 10, 1))’;
stage = cellstr(stage);
data_1 = table(time, stage, ‘VariableNames’, {‘time’, ‘stage’})
If I have another time series data,
stages = {‘A’, ‘B’, ‘C’};
stage = stages(randi(numel(stages), 10, 1))’;
stage = cellstr(stage);
data2 = table(time, stage, ‘VariableNames’, {‘time’, ‘stage’})
I wanted to know if there’s a simple way to get a final table (data) after taking an average of the stages at each duration timepoint. I thought of assigning the three stages A, B, and C integer values and then taking the average at each time point. The round off value that is the closest to the integer is assigned the same stage. For example, A = 0, B =1, C = 2. In the MWE above, at the first time point, we have the average = 0 so "data" will have A as the first stage.
I was wondering if there is a neater way to go about this. Or if there’s an inbuilt matlab tool that does this for us. Thank you!Hi, I have a time series data that loos like this:
time = repmat(5, 10, 1);
stages = {‘A’, ‘B’, ‘C’};
stage = stages(randi(numel(stages), 10, 1))’;
stage = cellstr(stage);
data_1 = table(time, stage, ‘VariableNames’, {‘time’, ‘stage’})
If I have another time series data,
stages = {‘A’, ‘B’, ‘C’};
stage = stages(randi(numel(stages), 10, 1))’;
stage = cellstr(stage);
data2 = table(time, stage, ‘VariableNames’, {‘time’, ‘stage’})
I wanted to know if there’s a simple way to get a final table (data) after taking an average of the stages at each duration timepoint. I thought of assigning the three stages A, B, and C integer values and then taking the average at each time point. The round off value that is the closest to the integer is assigned the same stage. For example, A = 0, B =1, C = 2. In the MWE above, at the first time point, we have the average = 0 so "data" will have A as the first stage.
I was wondering if there is a neater way to go about this. Or if there’s an inbuilt matlab tool that does this for us. Thank you! Hi, I have a time series data that loos like this:
time = repmat(5, 10, 1);
stages = {‘A’, ‘B’, ‘C’};
stage = stages(randi(numel(stages), 10, 1))’;
stage = cellstr(stage);
data_1 = table(time, stage, ‘VariableNames’, {‘time’, ‘stage’})
If I have another time series data,
stages = {‘A’, ‘B’, ‘C’};
stage = stages(randi(numel(stages), 10, 1))’;
stage = cellstr(stage);
data2 = table(time, stage, ‘VariableNames’, {‘time’, ‘stage’})
I wanted to know if there’s a simple way to get a final table (data) after taking an average of the stages at each duration timepoint. I thought of assigning the three stages A, B, and C integer values and then taking the average at each time point. The round off value that is the closest to the integer is assigned the same stage. For example, A = 0, B =1, C = 2. In the MWE above, at the first time point, we have the average = 0 so "data" will have A as the first stage.
I was wondering if there is a neater way to go about this. Or if there’s an inbuilt matlab tool that does this for us. Thank you! averaging labels, sum, mean MATLAB Answers — New Questions