function L = matchIDs(IDs, ch)
% Get all the clicker IDs that begins with the character in ch.
% IDs is a 2-d array of characters where each row is a clicker ID, e.g.
%   ['d091314'; ...
%    'a134d83'; ...
%    'fr83209']
% ch is a single character
% L is a cell array such that each cell is a clicker ID that begins with 
%  the character in ch.

[nr,nc] = size(IDs);

L= {};
k= 0;  % Number of matches so far
for r=1:nr
    if IDs(r,1)==ch
        k= k+1;
        L{k,1}= IDs(r,:);
    end
end


% It is better to directly assign something into a cell of the cell array 
% as shown above than to build a cell array through concatenation, as 
% shown below.  You could easily get unexpected results (and errors) when
% you concatenate cells and cell arrays.
% 
% L= {};
% for r= 1:nr
%     if IDs(r,1)==ch
%         L = [L; IDs(r,:)];
%     end
% end