www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/SelectVariablesInTableExample.m
%% Select Variables in Table % Create a table that contains numeric and string variables. Then subscript % into the table to get only its numeric variables. LastName = string({'Smith';'Johnson';'Williams';'Jones';'Brown'}); 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(LastName,Age,Height,Weight,BloodPressure) %% % Create a subscript with the |vartype| function. Subscript into the % second dimension of |T| to return a table that contains only the numeric % variables. S = vartype('numeric'); T2 = T(:,S) %% % You can create a subscript for any type that the |isa| function accepts. % Select the string variable from |T|. S = vartype('string'); T3 = T(:,S)