%% Calculate Mean Values of Groups of Data
% Calculate the mean heights by gender for groups of patients and display the results.
% Load patient heights and genders from the data file patients.mat.

load patients
whos Gender Height

%
% Specify groups by gender with findgroups.

G = findgroups(Gender);

%
% Split Height into groups specified by G. Calculate the mean height by gender. The first row of the output argument is the mean height of the female patients, and the second row is the mean height of the male patients.

splitapply(@mean,Height,G)

% Copyright 2015 The MathWorks, Inc.