Choose specific values from dataset

3 visualizaciones (últimos 30 días)
Jorg Borren
Jorg Borren el 4 de Mayo de 2022
Comentada: Jorg Borren el 4 de Mayo de 2022
I have the following dataset consisting of two columns, interrupted by random integers. How can I read the dataset (attached below) and keep only the first set of values (colored red in the picture) after each integer?

Respuesta aceptada

Stephen23
Stephen23 el 4 de Mayo de 2022
Editada: Stephen23 el 4 de Mayo de 2022
txt = fileread('demodata1.txt');
rgx = '^\s+\d+\s+(\S+)\s+(\S+)';
tkn = regexp(txt,rgx,'tokens','lineanchors');
mat = str2double(vertcat(tkn{:}))
mat = 4×2
0.3164 -0.3921 -0.1385 0.4998 0.4545 -0.2000 -0.1175 -0.1774

Más respuestas (0)

Categorías

Más información sobre Data Import from MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by