MATLAB: Seperate elements in cell array

arraycell

Hi everybody I have a massive cell array in the form of:
'GLD|41|R|10|05:28:06:361|01/08/2011|f98=158.6'
'GLD|41|T|10|05:28:06:361|01/08/2011|f2=158.3659'
'SLV|41|R|10|05:28:18:901|01/08/2011|f98=39.1628'
'SLV|41|T|10|05:28:18:901|01/08/2011|f2=38.8504'
'GLD|41|R|10|05:28:21:755|01/08/2011|f98=158.6'
'GLD|41|T|10|05:28:21:755|01/08/2011|f2=158.3659'
'SLV|41|R|10|05:28:34:285|01/08/2011|f98=39.1628'
It is always SLV or GLD.
How can I separate this cell array into two cell arrays where one is for all the SLV entries and one is for the GLD entries?
Thanks

Best Answer

I'm assuming each string above is one element of the cell array. To find the SLV and put them in a cell array.
X = {'GLD|41|R|10|05:28:06:361|01/08/2011|f98=158.6',...
'GLD|41|T|10|05:28:06:361|01/08/2011|f2=158.3659',...
'SLV|41|R|10|05:28:18:901|01/08/2011|f98=39.1628',...
'SLV|41|T|10|05:28:18:901|01/08/2011|f2=38.8504',...
'GLD|41|R|10|05:28:21:755|01/08/2011|f98=158.6',...
'GLD|41|T|10|05:28:21:755|01/08/2011|f2=158.3659',...
'SLV|41|R|10|05:28:34:285|01/08/2011|f98=39.1628'};
Y = cellfun(@(x)x(1:3),X,'UniformOutput',false);
Y1 = strcmp(Y,'SLV');
X1 = X(Y1>0);
Then X1 contains only the 'SLV' entries. You can do the same for 'GLD'.