Delete rows from text file that do not contain certain numbers

3 Ansichten (letzte 30 Tage)
Hi all, I am trying to delete all the lines that do NOT contain 1010001 and 1010003. Can anybody help how to make this job much easier?
Thanks, below is a bit of a data.
1010001,1960,1,67.1,-11.0
1010001,1960,2,101.0,-5.4
1010001,1960,3,56.3,-6.2
1010001,1960,4,77.5,2.1
1010001,1960,5,74.0,13.4
1010001,1960,6,91.1,15.9
1010001,1960,7,102.2,17.0
1010001,1960,8,67.8,17.1
1010001,1960,9,74.8,13.0
1010001,1960,10,96.7,5.3
1010001,1960,11,70.5,0.9
1010001,1960,12,89.3,-8.9
1010002,1960,1,67.1,-10.7
1010002,1960,2,104.5,-4.9
1010002,1960,3,56.8,-6.1
1010002,1960,4,77.3,2.3
1010002,1960,5,71.5,13.6
1010002,1960,6,91.6,16.0
1010002,1960,7,104.2,17.2
1010002,1960,8,60.8,17.2
1010002,1960,9,77.4,13.2
1010002,1960,10,101.2,5.3
1010002,1960,11,70.0,0.9
1010002,1960,12,87.1,-8.7
1010003,1960,1,70.9,-11.4
1010003,1960,2,98.1,-5.4
1010003,1960,3,57.4,-6.0
1010003,1960,4,78.2,1.8
1010003,1960,5,78.7,13.5
1010003,1960,6,87.5,15.9
1010003,1960,7,103.0,17.2
1010003,1960,8,76.7,17.3
1010003,1960,9,68.6,12.9
1010003,1960,10,90.9,5.2
1010003,1960,11,70.0,0.9
1010003,1960,12,100.7,-9.0
1010004,1960,1,77.5,-11.1
1010004,1960,2,108.6,-5.1
1010004,1960,3,58.4,-5.7
1010004,1960,4,80.4,2.1
1010004,1960,5,76.8,13.5
1010004,1960,6,108.8,16.0
1010004,1960,7,101.4,17.4
1010004,1960,8,48.8,17.5
1010004,1960,9,62.5,13.2
1010004,1960,10,100.0,5.4
1010004,1960,11,70.0,1.2
1010004,1960,12,106.9,-8.8
1010005,1960,1,95.2,-10.5
1010005,1960,2,104.2,-4.7
1010005,1960,3,58.9,-5.0
1010005,1960,4,68.7,2.9
1010005,1960,5,74.3,13.8
1010005,1960,6,106.6,16.4
1010005,1960,7,102.8,17.9
1010005,1960,8,30.9,17.9
1010005,1960,9,47.9,13.2
1010005,1960,10,98.7,5.6

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 9 Nov. 2014
a=importdata('file.txt')
a(~ismember(a(:,1),[1010001;1010003],'rows'),:)=[]

Weitere Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by