フィルターのクリア

How can I save multiple matrices from text file?

1 回表示 (過去 30 日間)
Liana Shpani
Liana Shpani 2018 年 6 月 25 日
コメント済み: Liana Shpani 2018 年 6 月 25 日
I want to read dynamically all the particle path information for each particle. The number of matrices I need will vary according to how many particles are in the simulation. I separated the matrices with the word "Particle" as shown in the results.txt file I am attaching here.
Thank you in advance!

採用された回答

Guillaume
Guillaume 2018 年 6 月 25 日
There are many ways to do this, here is one option:
contents = fileread('results.txt'); %read whole file at once
contents = strsplit(contents, 'Particle'); %split into cell array at particle
particles = cellfun(@(c) sscanf(c, '%f', [3 Inf])', contents(2:end), 'UniformOutput', false); %scan each section into a 3xN matrix
  1 件のコメント
Liana Shpani
Liana Shpani 2018 年 6 月 25 日
That did it! Thank you so much!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by