Save information associated with a text entry type
Mostrar comentarios más antiguos
Dear all
I am attaching a file called "exchange.txt" to this post. From line 46, you can see that blocks of entries like the following appear:
Cr2 Cr4 ( 0, 0, 0) 0.2393 ( 0.000, 0.000, 6.549) 6.549
J_iso: 0.2393
[Testing!] Jprime: 0.825, B: -0.328
[Testing!] DMI: (-0.0000 -0.0000 -0.0732)
[Testing!]J_ani:
[[-0.07 -0. 0. ]
[-0. -0.07 0. ]
[ 0. 0. -0.656]]
which are separated by dashed lines. Interestingly, as it can be seen in the aforementioned file, the last element of the first line of these blocks is a number that is equal to or greater than the equivalent one of the previous block, if such a thing exists.
My goal is to save some information from every text blocks that meet:
- that the first element of these blocks is "Cr2", and
- that the second element of these blocks is "Cr3" or "Cr4".
So whenever these conditions are met, I would like to be able to store the following information in different columns on the same row:
- the last element of the first line,
- the number that appears on the second line, and
- the three numbers that appear on the third line,
so that each line of the created variable has as many lines as the number of times conditions 1. and 2. above are verified, and five columns. In the text block I put above as an example, the information that would be stored would be: 6.549, 0.2393, 0, 0, -0.0732.
I asked two similar questions which were kindly answered by user @Stephen23:
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!