Import not consistent table data
이전 댓글 표시
Hi! Sorry again for a (maybe) naif question, but I have been struggling all day trying to figure out how I can import a not consistent .txt dataset. I show you in figure what I mean:

From that, I just need to extract the column with inside the blu limiters. I tried to set import option and get the column where those numbers are in by the following code:
opts = detectImportOptions(sample_txt_file);
disp([opts.VariableNames' opts.VariableTypes']);
opts = setvartype(opts,{'x1100071'},'char');
disp([opts.VariableNames' opts.VariableTypes']);
values = readtable(sample_txt_file,opts);
times = values{:,4};
As result, I got 4 table columns and then I extracted the last one, the one with numbers I need.

Checking on how I could change 'char' values into a numeric array I coded:
S = sprintf('%s',times{:});
D = sscanf(S, '%f');
So I got an array containing number values of all those from column 4 but still don't understand how it works or if there are more suitable ways to extract data from that dataset.
Hope you could help me and thank you again :)
댓글 수: 3
Mathieu NOE
2022년 11월 17일
hello
can you provide your txt file ?
Luca Castrogiovanni
2022년 11월 17일
Mathieu NOE
2022년 11월 18일
do you want separate blocks of data or everything in one block ?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!