How to extract numbers against a certain text name in a text file containing time stamp data

7 views (last 30 days)
The attached text contains a time stamp data for a 100 cycles in some random format. I am looking to exttract and plot let's say - THE data mentioned for 'DA2.0:' after the colon against the time stamps of 100 cycles. Which is the most relevant MATLAB function to be used in this situation?
Thanks.

Accepted Answer

Voss
Voss on 26 Mar 2024
str = fileread('sampletext.txt');
C = regexp(str,'DA2.0:(.*?)\r?\n','tokens');
vals = str2double([C{:}])
vals = 1x4
10 18 20 30
  2 Comments
Aparna Bhardwaj
Aparna Bhardwaj on 26 Mar 2024
Thank you very much for your prompt response. I will try to apply the above commands in my actual txt file which is a bit more complicated for plotting multiple figures.
Voss
Voss on 26 Mar 2024
You're welcome! If there are any problems using this code on the actual file, upload it here (maybe zip it first).

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!