how can I only display all the data?

5 visualizzazioni (ultimi 30 giorni)
Manav Divekar
Manav Divekar il 30 Gen 2022
Modificato: Voss il 30 Gen 2022
from this txt fike how can i just get the data and asign to a variable

Risposta accettata

Voss
Voss il 30 Gen 2022
Modificato: Voss il 30 Gen 2022
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

Più risposte (0)

Categorie

Scopri di più su Large Files and Big Data in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by