MATLAB - extract selected rows in a table based on some criterion

只谈情不闲聊 提交于 2019-12-06 13:38:33

Assuming myTable is your original table.

You can just do

myTable(myTable.user == 'A',:)

Sample Code:

user = ['A';'B';'A';'C';'B'];
Age = [38;43;38;40;49];
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
BloodPressure = [124 93; 109 77; 125 83; 117 75; 122 80];
T = table(user,Age,Height,Weight,BloodPressure)
T(T.user=='A',:)

Gives:

T =

user    Age    Height    Weight          BloodPressure      
____    ___    ______    ______    _________________________

A       38     71        176       124                    93
B       43     69        163       109                    77
A       38     64        131       125                    83
C       40     67        133       117                    75
B       49     64        119       122                    80

ans =

user    Age    Height    Weight          BloodPressure      
____    ___    ______    ______    _________________________

A       38     71        176       124                    93
A       38     64        131       125                    83
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!