Borrar filtros
Borrar filtros

Read text file and store in .mat file

6 visualizaciones (últimos 30 días)
Sudharsan
Sudharsan el 7 de Sept. de 2013
I have a text file with these values:
d030bcb1
6142d6ad
619b8312
618803cb
61866781
619c04c5
61c420b2
61ba1feb
61bec5b3
6221fe09
I want to read this text file and store in a .mat file.
thanks in advance

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 7 de Sept. de 2013
Editada: Azzi Abdelmalek el 7 de Sept. de 2013
fid = fopen('file1.txt');
A= textscan(fid,'%s');
fclose(fid);
celldisp(A)
save file2 A

Más respuestas (2)

Walter Roberson
Walter Roberson el 7 de Sept. de 2013
data = regexp( fileread('file1.txt'), '\n', 'split' );
save file2 data

Razvan
Razvan el 7 de Sept. de 2013
filename = 'example.txt';
fileID = fopen(filename,'r');
data = textscan(fileID, '%s\n');
data = data{1};
fclose(fileID);
save('example.mat', 'data')
  1 comentario
Sudharsan
Sudharsan el 7 de Sept. de 2013
Thanks Razvan
but this code writes only the first data i.e: d030bcb1 to the mat file.
can u help me further..

Iniciar sesión para comentar.

Categorías

Más información sobre Low-Level File I/O 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