%!demo
%! ## `splitapply` divides a table by the group numbers from `findgroups`, applies
%! ## a function to each group, and concatenates the results.  Here it computes a
%! ## mean petal length per species.
%!
%! Species = {'setosa'; 'virginica'; 'setosa'; 'virginica'; 'setosa'};
%! Petal = [1.4; 5.1; 1.5; 5.9; 1.3];
%! T = table (Species, Petal)
%! G = findgroups (T(:, 'Species'));
%! splitapply (@mean, T(:, 'Petal'), G)
%!
%! ## The applied function may return several outputs — one column each — and can
%! ## read several variables at once.
%! [lo, hi] = splitapply (@(x) deal (min (x), max (x)), T(:, 'Petal'), G);
%! [lo, hi]
