How to read text data for a given pattern?
이전 댓글 표시
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.
채택된 답변
추가 답변 (1개)
Image Analyst
2022년 12월 22일
0 개 추천
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:
카테고리
도움말 센터 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!