フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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

1 回表示 (過去 30 日間)
David André Gomez Romero
David André Gomez Romero 2019 年 3 月 8 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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 件のコメント
Bob Thompson
Bob Thompson 2019 年 3 月 8 日
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 2019 年 3 月 9 日
編集済み: David André Gomez Romero 2019 年 3 月 9 日
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.

回答 (0 件)

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by