Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Write a txt-file from a specific value in another txt-file

1 visualización (últimos 30 días)
David André Gomez Romero
David André Gomez Romero el 8 de Mzo. de 2019
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hello everyone,
I'm having some issues in order to write a txt-file from another txt-file. I want to supresse some part of the original txt-file and write only the essential information that I need. For exemple, in the original-txt file I have :
----------------------------------------------------------------------------------------------------------------------------------------------------
<Thelen2003Muscle name="Ps_L1_VB_r">
<!--The set of points defining the path of the muscle.-->
<GeometryPath>
<!--The set of points defining the path-->
<PathPointSet>
<objects>
<PathPoint name="PathPoint_lumbar1">
<location> -0.00057725 0.029429 0.02</location>
<body>lumbar1</body>
</PathPoint>
<PathPoint name="PathPoint_pelvis">
<location> -0.0238 -0.057 0.0759</location>
<body>pelvis</body>
</PathPoint>
</objects>
<groups />
</PathPointSet>
----------------------------------------------------------------------------------------------------------------------------------------------------
I want to write in my new txt-file, only the information of location, for exemple in my new txt-file I need :
----------------------------------------------------------------------------------------------------------------------------------------------------
<location> -0.00057725 0.029429 0.02</location>
<location> -0.0238 -0.057 0.0759</location>
----------------------------------------------------------------------------------------------------------------------------------------------------
I think I have to use fpintf, but my problem is to say : read from here to here and write this information here.
Thanks in advance, Dave.
  2 comentarios
Bob Thompson
Bob Thompson el 8 de Mzo. de 2019
Do you have any code written already? How are you choosing to load the file? Generally, with text files it is simplest to just read the entire file and then parse what you want from there.
David André Gomez Romero
David André Gomez Romero el 9 de Mzo. de 2019
Editada: David André Gomez Romero el 9 de Mzo. de 2019
Thanks Bob for the reply.
But I found the solution of my problem, like txt-file is in fact an XML. I juste use the function : xml2struct (found here : https://ch.mathworks.com/matlabcentral/fileexchange/58700-xml2struct-with-bug-fix-and-added-features).
I obtains a well structure in MatLab and I juste have to choose the information that I need in the structure to write it in my new txt-file.

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by