Find a word in a text file and read values from that line

3 ビュー (過去 30 日間)
aero123
aero123 2022 年 3 月 7 日
コメント済み: Arif Hoq 2022 年 3 月 8 日
Example :
File name: mhcb0020.03o
Rinex version: 2
File type: Observation
Satellite system: GPS
Position_reference (X/Y/Z): -2664065.576700 -4323178.973800 3848368.475300
Antenna-delta (H/E/N): 0.068700 0.000000 0.000000
I need to extract the 3 values after 'Position_reference(X/Y/Z)' from the text file.
Can you help me with this?
Thanks

回答 (1 件)

Arif Hoq
Arif Hoq 2022 年 3 月 7 日
A=readtable('example2.txt','delimiter',':');
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
output=table2array(A(4,2))
output = 1×1 cell array
{'-2664065.576700 -4323178.973800 3848368.475300'}
  2 件のコメント
Arif Hoq
Arif Hoq 2022 年 3 月 7 日
編集済み: Arif Hoq 2022 年 3 月 7 日
or if you want to find the string (Position_reference (X/Y/Z)) in the text file
A=readtable('example2.txt','delimiter',':','ReadVariableNames',false);
str=string(table2array(A));
[idx]=find(str=={'Position_reference (X/Y/Z)'});
output=str(idx,2) % string
output = "-2664065.576700 -4323178.973800 3848368.475300"
% for numeric result
format longG
numeric_output=rmmissing(str2double(split(output,' ')))
numeric_output = 3×1
1.0e+00 * -2664065.5767 -4323178.9738 3848368.4753
Arif Hoq
Arif Hoq 2022 年 3 月 8 日
Did that answer solve your problem ?

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

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by