How to extract data from diary?
이전 댓글 표시
Hello,
I've used the diary function to create a diary file. When I open the diary file, I've got the following:
normal
1.0e+03 *
1.1797 0.2894 0.0010
1.1797 0.2894 -0.0010
open
1.0e+03 *
1.1797 0.2894 0.0010
1.1797 0.2894 -0.0010
normal
1.0e+03 *
1.2787 0.5115 0.0010
1.2787 0.5115 -0.0010
Now, I want to capture all the numbers that follow after the word 'normal', so I only want the numbers depicted in bold here. How do I read the diary file in Matlab and extract the numbers I want from the diary file?
Thank you.
댓글 수: 2
Rik
2020년 6월 19일
The diary file is a plain text file, so you can read it like any other. Then you will have to select the lines that describe the values of normal, and make sure you correctly parse the factor.
If you want more specific help, you can attach the file to your question.
채택된 답변
추가 답변 (1개)
Jyotirmay Mishra
2020년 6월 19일
0 개 추천
Hi,
You can import the diary file as dataset from the import data option in the home tab of MATLAB. Make sure that you select the datatype for the first coloumn as Text or else the text ''normal", "open" will be replaced by NaN.
Now you can use some logic using the a loop and some conditional statements to obtain the data after normal
카테고리
도움말 센터 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!