Creating new table from another table
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Colin Leonelli
el 18 de Sept. de 2021
Respondida: Star Strider
el 18 de Sept. de 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 comentarios
Respuesta aceptada
Star Strider
el 18 de Sept. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre MATLAB Report Generator en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!