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

2 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

David Hill
David Hill am 2 Aug. 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,:);

Weitere Antworten (0)

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by