Clear Filters
Clear Filters

import data from .dat file

48 views (last 30 days)
Turbulence Analysis
Turbulence Analysis on 31 Oct 2023
Commented: Voss on 31 Oct 2023
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 Comments
Star Strider
Star Strider on 31 Oct 2023
Can you use the zip function to compress it and then upload it here?

Sign in to comment.

Accepted Answer

Voss
Voss on 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 Comments
Turbulence Analysis
Turbulence Analysis on 31 Oct 2023
Thank you very much !
Voss
Voss on 31 Oct 2023
You're welcome!

Sign in to comment.

More Answers (0)

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!