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

4 ビュー (過去 30 日間)
  13 件のコメント
Subaharan Rajenthirakumar
Subaharan Rajenthirakumar 2022 年 5 月 13 日
Thank you for the help and explanation.

サインインしてコメントする。

採用された回答

dpb
dpb 2022 年 5 月 12 日
編集済み: dpb 2022 年 5 月 12 日
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.

その他の回答 (0 件)

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by