Hello everybody!
I'm a beginner in MatLab, and I am blocking right now.
I have several files named like that: OutputFile_1, OutputFile_2, … OutputFile_40410 These files are constructed like that:
2008 5 1 0013 32.5 L -12.845 165.450 35.0 VAN 5 0.1 2.1LVAN 1GAP=355 0.33 36.9 81.8999.9 0.1882E+04 0.1078E+06 -0.8944E+04EACTION:UPD 16-09-24 15:16 OP:ocea STATUS: ID:20080501001332 L I2008-05-01-0013-55S.VNRC__051_MSEED 6STAT SP IPHASW D HRMM SECON CODA AMPLIT PERI AZIMU VELO AIN AR TRES W DIS CAZ7VSARABZ EP 0 014 14.65 91 -0.0610 312 148VSARABZ IAML 014 19.06 5.90 0.12 312 148VKOLHBZ EP 2 014 15.86 91 -0.04 5 321 145VKOLHBZ IAML 014 16.78 9.42 0.10 321 145VBUTMBZ EP 2 014 16.44 91 0.23 5 324 149VBUTMBZ IAML 014 16.65 5.91 0.10 324 149VBUTMBZ ES 3 014 50.35 91 0.01 2 324 149VIRHOBZ EP 2 014 19.00 91 0.17 5 345 147VIRHOBZ IAML 014 19.17 5.84 0.12 345 147VAVUNBZ EP 1 014 20.73 91 -0.05 7 359 150VAVUNBZ IAML 014 20.94 4.99 0.12 359 150
I would like to read all of these files, count the number of 'EP' and 'ES' occurrences, and if the number of 'EP' + 'ES' is higher than 8, stock the files in on unique file.
The first issue is that I'm not able to count the number of occurrences. I tried something like that:
clcclear allclose allFiles = dir(OutputFile_*);Nbr_Event = lenght(Files);for i = 1:Nbr_Event; fid = fopen('Files'); occ = cound (fid, 'EP');end
And I got this Error:
Error using count Search term must be a string array, character vector, or cell array of character vectors.
I tried with sum(fid=='EP') but I just obtained ans = 0.
I have the filling that it's not so complicated, but I'm not good enough in matlab to did it alone.
The aim after is to continue with something like that, I guess:
select_events = fopen('select_events.txt', 'w')if Occ >= 8;fprintf (Files, \n)
Thank you a lot for your help.
Best Answer