Borrar filtros
Borrar filtros

Import an oddly shaped txt file

1 visualización (últimos 30 días)
ayat
ayat el 29 de Mzo. de 2016
Respondida: KSSV el 29 de Mzo. de 2016
I have a txt file that is with a weird shape as you can see in the attached. When I use the import feature in matlab and choose nemeric matrix, the imported matrix looks like it should (each value allocated to the correct number on the second row). I don`t know how to replicate that in code. On a side note, is it possible to replace the "," with "." and then import?

Respuestas (1)

KSSV
KSSV el 29 de Mzo. de 2016
clc; clear all ;
file = 'B00001.txt' ;
fid = fopen(file,'r') ;
S=textscan(fid,'%s','delimiter','\n');
fclose(fid) ;
S = S{1} ;
All the file contents will be saved in cell S. You can do what ever you want from S.
Note that there are many other ways to read a file.

Categorías

Más información sobre Data Import and Analysis 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