How to extract two columns from cell table based on two conditions
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Aayma Mughal
am 1 Aug. 2022
Kommentiert: Aayma Mughal
am 4 Aug. 2022
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.
1 Kommentar
Akzeptierte Antwort
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)
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!