www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/SortRowsofTableExample.m
%% Sort Rows of Table % Sort the rows of a table by the variable values in ascending order. %% % Create a table with four variables listing patient information for five % people. LastName = {'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]; tblA = table(Age,Height,Weight,BloodPressure,'RowNames',LastName) %% % Sort the rows of the table. tblB = sortrows(tblA) %% % The |sortrows| function sorts the rows in ascending order first by the % variable |Age|, and then it sorts by the variable |Height|.