www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/UseUniqueGroupValuesInOutputTableExample.m
%% Use Unique Group Values in Output Table % Calculate the median heights for groups of patients, and display the results % in a table. To define the groups of patients, use the additional output % argument from |findgroups|. % % Load patient heights and genders from the data file |patients.mat|. % Copyright 2015 The MathWorks, Inc. load patients whos Gender Height %% % Specify groups by gender with |findgroups|. The values in the output % argument |gender| define the groups that |findgroups| finds in the % grouping variable. [G,gender] = findgroups(Gender); %% % Calculate the median heights. Create a table that contains the median heights. medianHeight = splitapply(@median,Height,G); T = table(gender,medianHeight)