import data from .dat file

61 次查看(过去 30 天)
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 个评论
Star Strider
Star Strider 2023-10-31
Can you use the zip function to compress it and then upload it here?

请先登录,再进行评论。

采纳的回答

Voss
Voss 2023-10-31
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by