Importing text file and reading certain values with key terms

2 ビュー (過去 30 日間)
John Vargas
John Vargas 2018 年 9 月 18 日
コメント済み: John Vargas 2018 年 9 月 21 日
Hello, I am trying to import this text file into matlab but only reading certain values. Ignoring the uncollided data, I want to be able to retrieve the location of each detector (x,y and z) , (z = 0 for all detectors). Also, I want to be able to retrieve the "total" value which can be found at the end of each collided data. I know this data that is being imported is very hard to convert to the values I need but I would appreciate any help. Thank you in advance.
  8 件のコメント
Paolo
Paolo 2018 年 9 月 18 日
If that is the case, try:
raw = fileread('D1output1.txt');
[~,tok] = regexp(raw,'x,y,z = (\d+\.\d+E\+\d+) (\d+\.\d+E\+\d+)(-\d+\.\d+E\+\d+)\s*\n\s(?!uncollided)','match','tokens');
data=[tok{:}];
x=str2double(data(1:3:end));
y=str2double(data(2:3:end));
z=str2double(data(3:3:end));
John Vargas
John Vargas 2018 年 9 月 21 日
Sorry for the late reply, but when I tried running this code, I get the coordinates for each x and y as a matrix of 1x80 but there should be a total of 100 collided points, thus getting a matrix of 1x100. Do you know why this is the case?

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by