Creating new table from another table
8 views (last 30 days)
Show older comments
Colin Leonelli
on 18 Sep 2021
Answered: Star Strider
on 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 Comments
Accepted Answer
Star Strider
on 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 Comments
More Answers (0)
See Also
Categories
Find more on MATLAB Report Generator in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!