function [grps, X] = analgroup(sp)
%% dividing samples into two groups
% Input
%      sp: the matrix of data
% Output:
%      grps:  the structure of each class
%      X:  the samples in each class

grp = fieldnames(sp);
ngrp  = size(grp,1);

k = 0; X = []; ind = 0;
for i = 1:ngrp
    eval(['gsp = sp.' char(grp(i)) ';']);
    m = size(gsp,1);
    k = k + 1;
    grps(k).class = grp(i);
    grps(k).data = gsp;
    X = [X; grps(k).data];
    grps(k).size = size(grps(k).data,1);
    grps(k).index = ind+1:ind+grps(k).size;
    ind = ind + grps(k).size;
end
