Split Data Into Parts

12 visualizaciones (últimos 30 días)
Amadi Gabriel Udu
Amadi Gabriel Udu el 7 de Abr. de 2021
Comentada: Alan Stevens el 9 de Abr. de 2021
%% I have a set of table data of different columns of a patients data. I intend to split the data into various zones using the Breathing Pattern values.
In this case, I have plotted the Oxygen Level as rises and falls.
So I intend to split the Breathing Readings into 4 zones.
-First Zone when it is below a certain threshold say >100, (See Image from 0 - 1300 seconds)
- Second Zone when Oxygen Levels go from 100 to 500 (from 1301 - 1400 seconds)
- Third Zone when it drops from 500 to 100 (from 1401 - 1650 seconds)
- Fourth Zone when it goes below (1651 seconds - end)
N.B. I have another variable that could tell me when there is not signifcant breathing activity (ie. for First and Fourth Zone) if this would be need to increase the fidelity of the first and fourth zone
I tried to use mat2cell to split and do my 4 plots but I don't seem to get the hang of it.
%Converting Table to Matrix
dataAllMatrix = table2array(dataAll);
%% Plot Data for One Patient
PatientNumber = 75;
% 'end -1' (24 columns - 1 = 23)
PatientNumber_idx = find(dataAllMatrix(:,end-1)== PatientNumber);
Time = dataAllMatrix(PatientNumber_idx(1):PatientNumber_idx(end),1);
Oxygen_Level = dataAllMatrix(PatientNumber_idx(1):PatientNumber_idx(end),24);
figure
plot (Time, Oxygen_Level);
xlabel('Time(s)')
ylabel('Oxygen Level (mol)')
Patient_Title = ['Patient ', num2str(PatientNumber)];
title(Patient_Title)
%% Split Patient's Oxygen Level Data to 4 Zones (BP_area_1, BP_area_2, BP_area_3, BP_area_4)
Zone_1 = find(Oxygen_Level(:, end) < 100);
C = mat2cell(Oxygen_Level, Zone_1)
plot (C)

Respuestas (1)

Alan Stevens
Alan Stevens el 7 de Abr. de 2021
Aren't there five zones? Identify by something like:
z1 = find(oxygenlevel>100,'first'); % index to end of first zone
z2 = find(oxygenlevel>500,'first'); % index to end of second zone/start of third zone
z3 = find(oxygenlevel>500,'last'); % index to end of third zone/start of fourth zone
z4 = find(oxygenlevel>100,'last'); % index to end of fourth zone/start of last zone
t1 = Time(1:z1); % times in zone 1
t2 = Time(z1:z2); % times in zone 2
t3 = Time(z2:z3); % times in zone 3
t4 = Time(z3:z4); % times in zone 4
t5 = Time(z4:end); % times in zone 5
% etc.
  3 comentarios
Amadi Gabriel Udu
Amadi Gabriel Udu el 8 de Abr. de 2021
I get an error, saying
'Second argument must be a positive scalar integer'.
I was trying to also make a plot of the first zone
Alan Stevens
Alan Stevens el 9 de Abr. de 2021
Without the actual data, it's not really possible to help further!

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by