How can i extract all element except 'SP' 'NS''GX' and need to put it as a colum with numeric columns?

1 回表示 (過去 30 日間)
I have 100 data set like follows, 'GX' is always in the end, but 'SP', 'NS' positions can change other data sets. I would be thankful, if someone can suggest a coding for this..
'SP'
'NS'
'GS'
'GS'
'GS'
'GS'
'GS'
'GS'
'GS'
'GS'
'GS'
'GS'
'NS'
'GS'
'SP'
'GS'
'GS'
'GS'
'GS'
'NS'
'GS'
'GS'
'GA'
'GA'
'GA'
'NS'
'GS'
'GS'
'GS'
'GS'
'GS'
'NS'
'GS'
'GS'
'GS'
'GS'
'GS'
'NS'
'GS'
'GS'
'GS'
'GS'
'GS'
'NS'
'GS'
'GS'
'GS'
'GS'
'GS'
'NS'
'GS'
'GS'
'GS'
'GX'

回答 (1 件)

Arnab Sen
Arnab Sen 2016 年 2 月 24 日
Hi Nadeera,
I am assuming that you have a set of cell arrays each of which represents the data set and you would like to extract the data which does not match some specific string. Please find below a sample script demonstrating this:
%Assume that cell array A represent the data set.
>>B={'SP','NS','GX'};
>>C={};
>>len=length(A);
>>for i=1:len
if( isempty( find(cellfun('length',regexp(B,A{i})) == 1)))
C{end+1}=A{i}
end
end
The above script will extract all the elements in 'A' which are not present in 'B' and store them in another cell array 'C'.

カテゴリ

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