Hi,
I intend to read data from the .dat file. Here each data set is sperated by '&', so if I use below script, it just reads only the first eight rows. However, I need to read the entire data stored in the .dat file.
B=importdata('test.dat');
Output data = B.data;

4 commentaires

Star Strider
Star Strider le 31 Oct 2023
How does importdata read the file? It looks like it could be some sort of fixed-width format, since everything looks to be run together (using a non-monospace font to display it).
Turbulence Analysis
Turbulence Analysis le 31 Oct 2023
It reads based on the title in the header. The title of each column is in the first row of the .dat file.
Star Strider
Star Strider le 31 Oct 2023
Can you use the zip function to compress it and then upload it here?
Turbulence Analysis
Turbulence Analysis le 31 Oct 2023
PFA

Connectez-vous pour commenter.

 Réponse acceptée

Voss
Voss le 31 Oct 2023
fn = unzip('test.zip')
fn = 1×1 cell array
{'test.dat'}
T = readtable('test.dat','FileType','text','Delimiter','\t','MultipleDelimsAsOne',true)
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
T = 899×12 table
x_x T H2 N2 O2 CO H2O CO2 CH4 C2 n_image roi ___ ______ _____ ____ ____ ___ ____ ___ ___ ___ _______ ___ 0 293.18 99.7 0.11 0.1 -1 0.1 -1 -1 -1 1 0 1 297.42 99.64 0.2 0.08 -1 0.08 -1 -1 -1 1 1 2 296.23 99.74 0.1 0.08 -1 0.07 -1 -1 -1 1 2 3 297.42 99.48 0.19 0.26 -1 0.07 -1 -1 -1 1 3 4 290.86 99.7 0.08 0.14 -1 0.08 -1 -1 -1 1 4 5 297.43 99.68 0.16 0.08 -1 0.08 -1 -1 -1 1 5 6 288.27 99.49 0.09 0.27 -1 0.15 -1 -1 -1 1 6 7 288.65 99.68 0.11 0.11 -1 0.11 -1 -1 -1 1 7 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 2 0 1 293.08 99.7 0.14 0.08 -1 0.08 -1 -1 -1 2 1 2 299.51 99.72 0.08 0.1 -1 0.1 -1 -1 -1 2 2 3 -1 -1 -1 -1 -1 -1 -1 -1 -1 2 3 4 287.08 99.72 0.12 0.08 -1 0.08 -1 -1 -1 2 4 5 292.26 99.76 0.08 0.08 -1 0.08 -1 -1 -1 2 5 6 291.93 99.48 0.16 0.09 -1 0.27 -1 -1 -1 2 6

2 commentaires

Turbulence Analysis
Turbulence Analysis le 31 Oct 2023
Thank you very much !
Voss
Voss le 31 Oct 2023
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Import and Analysis dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by