Creating new table from another table
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Colin Leonelli
il 18 Set 2021
Risposto: Star Strider
il 18 Set 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 Commenti
Risposta accettata
Star Strider
il 18 Set 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su MATLAB Report Generator in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!