필터 지우기
필터 지우기

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