필터 지우기
필터 지우기

how can I only display all the data?

조회 수: 3 (최근 30일)
Manav Divekar
Manav Divekar 2022년 1월 30일
편집: Voss 2022년 1월 30일
from this txt fike how can i just get the data and asign to a variable

채택된 답변

Voss
Voss 2022년 1월 30일
편집: Voss 2022년 1월 30일
If your version of MATLAB is R2019a or newer, you can use readmatrix():
filename = 'DHD_10%_sec_T1.txt';
data = readmatrix(filename);
format long
data
data = 20275×3
-0.000050862627887 -0.124530710279942 0.008000000379980 -0.000050862627887 -0.112610071897507 0.008999999612570 -0.000050862627887 -0.098028592765331 0.009999999776483 -0.000050862627887 -0.083013646304607 0.010999999940395 -0.000050862627887 -0.069782592356205 0.012000000104308 -0.000050862627887 -0.059479601681233 0.013000000268221 -0.000050862627887 -0.052053701132536 0.014000000432134 -0.000050862627887 -0.048166055232287 0.014999999664724 -0.000050862627887 -0.047958608716726 0.016000000759959 -0.000050862627887 -0.051448512822390 0.017000000923872
In older versions (or just as an alternative), you can use fscanf():
filename = 'DHD_10%_sec_T1.txt';
fid = fopen(filename);
for i = 1:8 % skip 8 header lines
fgetl(fid);
end
data = reshape(fscanf(fid,'%g'),3,[]).';
fclose(fid);
format long
data
data = 20275×3
-0.000050862627887 -0.124530710279942 0.008000000379980 -0.000050862627887 -0.112610071897507 0.008999999612570 -0.000050862627887 -0.098028592765331 0.009999999776483 -0.000050862627887 -0.083013646304607 0.010999999940395 -0.000050862627887 -0.069782592356205 0.012000000104308 -0.000050862627887 -0.059479601681233 0.013000000268221 -0.000050862627887 -0.052053701132536 0.014000000432134 -0.000050862627887 -0.048166055232287 0.014999999664724 -0.000050862627887 -0.047958608716726 0.016000000759959 -0.000050862627887 -0.051448512822390 0.017000000923872

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by