Effacer les filtres
Effacer les filtres

Finding a word in text file

28 vues (au cours des 30 derniers jours)
Hülya Sukas
Hülya Sukas le 19 Juil 2019
Hello everyone
I have a text file and I want to find a specific keyword in this document. The document is similar with that:
A Student Number: 1516A465 Engineering Mathematics 3rd grade
B Student Number: 1818B165 Optimization Class 1st grade
Fall-Semester
Teacher: A A
G Student Number: 121A4161 Physics 1st grade
A Student Number: 4A45645B Statics 2nd grade
B Student Number: 1212A465 Calculus 2nd grade
Spring-Semester
Success level: %48
As you can see there are several properties in this document such as names,class,student numbers and some extra lines. I just need to find all of this student numbers which is shown as "Student Number:". Is there any way to do this automatically?
Thanks in advance.
Hulya.

Réponse acceptée

madhan ravi
madhan ravi le 19 Juil 2019
s=fileread('sample.txt'); % your text file's name
W = regexp(s,'Student Number: (\w*)','tokens');
Wanted = [W{:}].'
  4 commentaires
Hülya Sukas
Hülya Sukas le 19 Juil 2019
Anyway thanks again.
narimane misilmani
narimane misilmani le 13 Déc 2022
Hello madhan,
Eigenvalues computed with ARPACK in double precision
Mode counter real part imaginary part
19 9.31012E-05 0.00000E+00
23 -1.82916E-04 0.00000E+00
7 2.60740E-04 0.00000E+00
46 6.06788E-04 0.00000E+00
50 -1.56225E-03 0.00000E+00
1 6.26122E-03 0.00000E+00
26 -6.70405E-03 0.00000E+00
54 -1.25759E-02 0.00000E+00
2 1.35514E-02 0.00000E+00
30 -2.77108E-02 0.00000E+00
27 -5.97877E-02 0.00000E+00
5 6.62709E-02 0.00000E+00
49 -8.21084E-02 0.00000E+00
44 9.16752E-02 0.00000E+00
57 -1.63043E-01 0.00000E+00
48 -2.15720E-01 0.00000E+00
29 2.88138E-01 0.00000E+00
28 3.81950E-01 0.00000E+00
59 -4.38479E-01 0.00000E+00
56 -5.39008E-01 0.00000E+00
Modal excitation coefficients
Mode counter real part imaginary part
19 1.09799E-06 0.00000E+00
23 1.60449E-05 0.00000E+00
7 -1.39962E-06 0.00000E+00
46 2.56361E-04 0.00000E+00
50 1.25975E-06 0.00000E+00
1 -1.50107E-03 0.00000E+00
26 6.66658E-04 0.00000E+00
54 6.54069E-07 0.00000E+00
2 3.81054E-07 0.00000E+00
30 -1.57020E-03 0.00000E+00
27 9.99679E-07 0.00000E+00
5 -7.84969E-05 0.00000E+00
49 6.11713E-03 0.00000E+00
44 -5.31718E-07 0.00000E+00
57 -1.77614E-06 0.00000E+00
48 -4.62110E-03 0.00000E+00
29 5.84226E-08 0.00000E+00
28 -3.09276E-03 0.00000E+00
59 7.39256E-03 0.00000E+00
56 -4.45852E-06 0.00000E+00
I have this txt file, i want to take just the nb of mode counter, is it possible to find the word " mode counter" and then take the columns of nb?
thank you

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by