Creating new table from another table
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Colin Leonelli
am 18 Sep. 2021
Beantwortet: Star Strider
am 18 Sep. 2021
I have a 4 column table with ages, FEV values, Heights and the last has 1s or 0s. 1 means they smoke, 0 means they don't.
I need to make a new table with ages 11 and up, who smoke, and include their FEV values
0 Kommentare
Akzeptierte Antwort
Star Strider
am 18 Sep. 2021
A relatively efficient way is just to do the comparisons to create a logical vector (‘Lv’ here), and go with that —
T0 = table(randi([5 90],20,1), 100*rand(20,1),randi([100 200],20,1),randi([0 1],20,1), 'VariableNames',{'Age','FEV_1','Height','Smokes'})
Lv = T0{:,1}>=11 & T0{:,4}==1;
T1 = T0(Lv,:)
Experiment to get different results.
.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Report Generator finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!