フィルターのクリア

seperate elements in cell array

3 ビュー (過去 30 日間)
Mate 2u
Mate 2u 2012 年 4 月 5 日
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

採用された回答

Wayne King
Wayne King 2012 年 4 月 5 日
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'.
  1 件のコメント
Mate 2u
Mate 2u 2012 年 4 月 6 日
Great work.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by