How to get the highlighted parts from the text file to another separate text file?

4 views (last 30 days)
  13 Comments

Sign in to comment.

Accepted Answer

dpb
dpb on 12 May 2022
Edited: dpb on 12 May 2022
D=readlines('SB_PB.txt');
ix=find(contains(D,'NODE FOOT'));
NodeData=str2double(split(strtrim(D(i+3))));
to simplify the solution using arrayfun in earlier comments.
NB: Use of new(ish) split() function for strings in place of venerable non-vectorized strsplit requiring the looping construct.
>> NodeData=str2double(split(strtrim(D(ix+3))))
NodeData =
3159 36.019
1558 28.761
6466 20.324
>>
As opposed to the nonvectorized strsplit
>> strsplit(strtrim(D(ix+3)))
Error using strsplit (line 80)
First input must be either a character vector or a string scalar.
>>
which thus needs the looping construct.

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by