How to read text data for a given pattern?
Afficher commentaires plus anciens
Greetings!
I have a text file with the following format.
r e s u l t a n t s a n d s t r e s s e s f o r t i m e s t e p 1 ( at time 0.00000E+00 )
element # =1 part ID = # material type= #
resultants axial shear-s shear-t moment-s moment-t torsion pl eps
0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
integration point
sigma 11 sigma 12 sigma 31 plastic eps
1 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
2 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
3 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
4 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
element # =2 part ID = # material type= #
resultants axial shear-s shear-t moment-s moment-t torsion pl eps
0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
integration point
sigma 11 sigma 12 sigma 31 plastic eps
1 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
2 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
3 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
4 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
element # =3 part ID = # material type= #
resultants axial shear-s shear-t moment-s moment-t torsion pl eps
0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
integration point
sigma 11 sigma 12 sigma 31 plastic eps
1 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
2 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
3 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
4 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
element # =4 part ID = # material type= #
resultants axial shear-s shear-t moment-s moment-t torsion pl eps
0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.000E+00
integration point
sigma 11 sigma 12 sigma 31 plastic eps
1 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
2 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
3 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
4 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
The whole data repeats 500 times giving different values at respective times for all 4 element data.
I am trying to create a script that can extract the time (value after "at time"), element number (i.e. 1,2,3,4), and the axial, shear-s and shear-t for all the 500 iterations. Everything else is ignored.
Using 'for' loop, I was able to extract time values, but I am stuggling with extracting the axial, shear-s, and shear-t since my loop is for 500 but these values are present after every iteration for 4 elements, giving a total of 2000 values.
How can I script this to extract the values in an array?
Thanking in advance,
Warm regards.
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 22 Déc 2022
0 votes
You'll need to write a custom reader for that specialized format.
If you have any more questions, then attach your text file with the paperclip icon after you read this:
1 commentaire
MatLim
le 23 Déc 2022
Catégories
En savoir plus sur Image Processing Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!