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

1 view (last 30 days)
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'

Answers (1)

Arnab Sen
Arnab Sen on 24 Feb 2016
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'.

Categories

Find more on Cell Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!