Borrar filtros
Borrar filtros

read from a txt file

1 visualización (últimos 30 días)
Alexandros
Alexandros el 25 de Nov. de 2011
I have a txt file that looks like
time1,system1,system2,system3
[sec],[m],[m],[m]
1 AM, 1,2,3
2 AM, 1,2,3
3 AM, 1,2,3
I want to take that into matlab and then transfer it to excel every cell under it
By doing
dir = fopen(text.txt)
D = textscan(dir, '%s %s %s %s', 'delimited', ',')
I get a 4 cell arrays which includes all the data. so cell 1 has all the colum for time 1, cell 2 all the column for system1 e.t.c
when i do xlswrite (test.xls, D, 1, 'A1') it doesn't want to paste it
Do you have any ideas? I could use the dlmread function (only for numerical data) but i really need to paste also the time1 column with AM or without AM i don't care. But dlmread doesnt work if there is text in there and it colides with AM
Any ideas Thank you
  1 comentario
Jan
Jan el 25 de Nov. de 2011
Instead of "it doesn't want to paste it" a copy of the error message would be more helpful. Do you have problems with the file name -forgot the quotes?- or with the data in D -no nested cells allowed-?

Iniciar sesión para comentar.

Respuesta aceptada

Jan
Jan el 25 de Nov. de 2011
E = cat(2, D{:});
xlswrite('test.xls', E, 1, 'A1');
  1 comentario
Alexandros
Alexandros el 25 de Nov. de 2011
This is exactly what I needed.
Thank you so much

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