Write a for loop that converts the Data (Data.data) in the text file into matrix of 13 by 31 or 31 by 13.

2 visualizaciones (últimos 30 días)
The data should be imported and converted into a matrix of 13 x 31.

Respuesta aceptada

DGM
DGM el 12 de Abr. de 2022
This should be one way:
alltext = split(fileread('Textfile.txt'),newline);
allnums = regexp(alltext(1:end-1),'(?<=:\s*)[+-E\d]+','match');
allnums = cellfun(@str2double,allnums);
allnums = reshape(allnums,13,[])
  2 comentarios
DGM
DGM el 12 de Abr. de 2022
for k = 1
alltext = split(fileread('Textfile.txt'),newline);
allnums = regexp(alltext(1:end-1),'(?<=:\s*)[+-E\d]+','match');
allnums = cellfun(@str2double,allnums);
allnums = reshape(allnums,13,[])
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by