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'
0 个评论
回答(1 个)
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 Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!