how can I only display all the data?

3 次查看(过去 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 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by