.txt to matrix separated by blank lines

2 visualizaciones (últimos 30 días)
alyse tran
alyse tran el 25 de Jun. de 2021
Respondida: Nikhil Sapre el 25 de Jun. de 2021
I have txt files of 2 columns, where different trials are separated by two blank lines. How can I convert this data into matrices, where each trial is in a different matrix? Thank you for any help.

Respuestas (1)

Nikhil Sapre
Nikhil Sapre el 25 de Jun. de 2021
Hi Alyse,
Can you try something similar to this?
FileList = dir('*.txt');
[~,idx] = sort([FileList.datenum]);
FileData = [];
for iFile = 1:numel(idx)
currFile = FileList(idx(iFile)).name;
FileData.(['file_' num2str(iFile)]) = load(currFile);
end
Make sure your current directory is your .txt files are located.
Thanks,
Nikhil

Categorías

Más información sobre File Operations 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