Import .txt file and sorting the data from the title

1 回表示 (過去 30 日間)
Rodeo Thompson
Rodeo Thompson 2018 年 9 月 1 日
編集済み: Walter Roberson 2018 年 9 月 2 日
.txt looks like this:
R_ASIS_X 1015.56
R_ASIS_Y 218.86
R_ASIS_Z 939.91
I need to import this data from the .txt into matlab variables. I need a way to search for each variable like 'R_ASIS_X' and then when it's found in the .txt I need to save the corresponding data to the right into a variable.
Can somebody help me with this?
  2 件のコメント
madhan ravi
madhan ravi 2018 年 9 月 1 日
Can upload the text file?
Rodeo Thompson
Rodeo Thompson 2018 年 9 月 1 日
this is it. Do you know a way to search the txt for certain string and then get the value to the right?

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

採用された回答

Walter Roberson
Walter Roberson 2018 年 9 月 1 日
Your data file does not have variables named 'position' or 'speed' or 'acceleration'. But you can do, for example,
t = readtable('Marker Coordinate Data.txt', 'ReadVariableName', 0, 'ReadRowNames', 1);
R_ASIS_X = t{'R_ASIS_X', 1};
  1 件のコメント
Rodeo Thompson
Rodeo Thompson 2018 年 9 月 2 日
really really helpful. Thanks a lot.

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

その他の回答 (1 件)

ahmed nebli
ahmed nebli 2018 年 9 月 1 日
this link may help you https://www.mathworks.com/help/matlab/ref/fscanf.html

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by