필터 지우기
필터 지우기

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Analytics Toolbox에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by