How to extract two columns from cell table based on two conditions

2 visualizaciones (últimos 30 días)
Hello,
I have a data set that has sodium levels (numerical) in column 9 and blood pressure (logical) in column 6.
I want to create new table that has all sodium values <135 and all blood pressure values = 1.
When I use this, it returns the index.
measure_sodium = heart([heart{:,9}] < 135)
Same with this but with added blood pressure.
measure_sodium = heart([heart{:,9}] < 135 & [heart{:,6}] == 1 )
celldisp(measure_sodium) will individually print out the indices also not the actual values.
How can I return the actual values and not just the indices?
Thank you for your help.

Respuesta aceptada

David Hill
David Hill el 2 de Ag. de 2022
It is all number so I would convert to a matrix.
H=cell2mat(heart(:,[6,9]));
mesure_sodium=H(H(:,6)==1&H(:,9)<135,:);

Más respuestas (0)

Categorías

Más información sobre Data Distribution Plots 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