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일
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 2023년 10월 31일
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 2023년 10월 31일
Can you use the zip function to compress it and then upload it here?
Turbulence Analysis
Turbulence Analysis 2023년 10월 31일
PFA

댓글을 달려면 로그인하십시오.

 채택된 답변

Voss
Voss 2023년 10월 31일

0 개 추천

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

Turbulence Analysis
Turbulence Analysis 2023년 10월 31일
Thank you very much !
Voss
Voss 2023년 10월 31일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

질문:

2023년 10월 31일

댓글:

2023년 10월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by